17

My project works and builds successfully on my Mac but I cloned from github and although Android Studio appears to work normally, the project wouldn't build. I setup this project using Kotlin DSL.

Gradle sync failed: could not find extension implementation class org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRoot

Tried invalidate cache, removed all .gitignore rules but it's still the same. Any ideas?

Mbuodile Obiosio
  • 1,463
  • 1
  • 15
  • 19

7 Answers7

46

I had the same issue (Note : Running Linux/Ubuntu 20.04 LTS and Android Studio 4.1.1).

Things I tried that did NOT work and error persisted :

  • Invalidate Caches / Restart
  • Reboot
  • Nuking the .gradle and .m2 folders
  • Android Studio re-install
  • Downgrade kotlin gradle plugin from 1.4.21 to 1.4.10

What did work :

  • Moving the project to a different folder/location on disk and open Android Studio

As soon as I moved the project back to the original location I would start getting the same error. This lead me to believe it was some sort of caching issue, separate from the caches "invalidated".

Solution :

Android Studio / Intellij creates a hidden folder called :

On Linux :

AS : ~/.cache/Google/AndroidStudioX.X

IJ : ~/.cache/Jetbrains/IntelliJIdea2020.X

On Mac :

AS : ~/Library/Caches/Google/AndroidStudioX.X

IJ : ~/Library/Caches/Jetbrains/IntelliJIdea2020.X

On Windows:

AS : %HOME%\AppData\Local\Google\AndroidStudioX.X

IJ : %HOME%\AppData\Local\Jetbrains\IntelliJIdea2020.X

Inside this folder are other various folders, however I removed the relevant workspace file (workspace/[project name].[hashed value].xml) after which problem went away when opening the project again, from its original location.

So it appears that "Invalidate Caches / Restart" does not "Invalidate" all caches!

I hope this resolves you problem!

Update

As this answer has had quite a few upvotes it would appear that this might be a ongoing bug with Intellij. If anyone has this problem, before resolving with the suggested solution consider checking there isn't an open issue on the bug tracker and submitting a new issue : https://youtrack.jetbrains.com/issues

Feel free to edit this update with issue if one is opened.

Update 2

Issue opened by @GeniusRUS :

https://youtrack.jetbrains.com/issue/KT-44937

Mark
  • 9,604
  • 5
  • 36
  • 64
  • Man, you may have just accomplished all Napoleon couldn't do. I'm on the same OS and AS so I'll definitely give this a shot. I'll come back with update. – Mbuodile Obiosio Dec 28 '20 at 01:53
  • 1
    This handled it. A special thank you for digging in and finding this then sharing. You just saved me serious headache. – Mbuodile Obiosio Dec 28 '20 at 09:24
  • I'm not sure of the analogy but glad the problem is solved. – Mark Dec 28 '20 at 12:42
  • 3
    For those who are on Mac, the cache folder path looks like this: "~/Library/Caches/Google/AndroidStudio4.1/workspace" – amatkivskiy Dec 29 '20 at 14:27
  • @amatkivskiy thanks for the information on hidden directory on Mac OS - I have added as an edit. – Mark Dec 29 '20 at 15:07
  • 1
    Had the same issue with Intellij and multiplatform. This worked. ~/Library/Caches/Jetbrains/IntelliJIdea2020.X/workspace/YOUR_PROJECT.xml – Sean Keane Feb 01 '21 at 19:12
  • Well done. Thanks a lot !! I solved gradle message error "Gradle sync failed: could not find extension implementation class ...GradleBuildRootsManager" using only the approach that removes the cache files from ~/.cache/Google/AndroidStudio4.1/workspace/[my-project-xml] – e2a Feb 04 '21 at 16:26
  • upgrading the JDK worked for me (in my case, JDK 8) – user64141 Feb 05 '21 at 19:39
  • 1
    Is there any IJ/AS issue on some issue tracker for these products that we can upvote/star, so that this issue might receive higher priority? – Erik Feb 08 '21 at 13:55
  • 1
    @Erik I have had look at the issue tracker and couldn't find anything similar. I have been waiting for the problem to happen to me again so I could raise the problem on the tracker - so far I haven't had it happen again. Unless I can provide the relevant information to the issue tracker it will just get closed . Call to anyone with the issue, before resolving please open a bug and relevant infomation. – Mark Feb 08 '21 at 14:00
  • Thank you so much. This worked perfectly. – Marty Miller Mar 09 '21 at 02:41
3

For Mac users delete the following file:

~/Library/Caches/Google/AndroidStudio4.1/workspace/<your_project_name>.58dfbe93.xml

PS: Thanls @Mark Keen for solution.

amatkivskiy
  • 1,154
  • 8
  • 11
2

basically i deleted .idea folder and then invalidate and restart ... error goes away and built successfull.

1

This probably isn't the "correct" solution, however, it worked for me. I had to download a newer (Canary) Version of Android Studio to get this error message to go away and to finally build my Android project once again. I found this YouTrack JetBrains issue where people also suggested reverting to previous, known working, versions of Android Studio to get their projects to build again.

This is a SUPER frustrating issue and I hope that one of the approaches resolves your build issues for you!

Here are the Android Studio Versions Download page for convenience.

Payne Miller
  • 134
  • 1
  • 8
1

After moving projects and files around I had also the honor to enjoy this error in Android Studio 4.1.1 (under Windows 10). Unfortunately, none of the above solutions worked for me but they helped me to narrow down the issue.

So, I found that there is a folder with workspaces under:

%HOME%\AppData\Local\Google\AndroidStudio4.1\workspace\

There are a couple of *.xml files named like the android projects. I deleted the one that didn't work.

Then switched back to Android Studio and used the Files > Invalidate Caches / Restart... feature. Android Studio restarted and the problem was fixed.


Bonus: How I found the workspace folder?

I used the Procmon.exe from Sysinternals where I filtered by the Process Name = studio64.exe. I then used the elephant-with-the-arrow button (Sync Project with Gradle Files) in Android Studio. At the end of the recording there was the workspace folder that Android Studio used just before Gradle failed.

t3chb0t
  • 16,340
  • 13
  • 78
  • 118
1

I added a "problem" ticket to YouTrack, where I described my case in detail. The support agent said the issue has already been fixed in the IDEA 2021.1 platform. And also gave recommendations for this case

Link to issue https://youtrack.jetbrains.com/issue/KT-44937

GeniusRUS
  • 11
  • 2
0

I fixed the issue by changing the root project directory name. You can try that.

Cafer Mert Ceyhan
  • 1,640
  • 1
  • 13
  • 17