could not find extension implementation class org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager

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


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