我也有同样的问题(注意:运行Linux/Ubuntu 20.04 LTS和Android Studio 4.1.1).
Things I tried that did NOT work and error persisted :
- Invalidate Caches / Restart
- 重启
- 对
.gradle
和.m2
文件夹进行核爆
- Android Studio re-install
- 将kotlin gradle插件从
1.4.21
降级到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
在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.
因此,"使缓存失效/重新启动"似乎不会使所有缓存失效!
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个