更新时间:2023-11-22 18:45:28
注意:这纯粹是 IDEA/AS 问题,gradlew clean
|构建 > 清洁 |Build > Rebuild 只会浪费你的时间.
Note: this is purely an IDEA/AS issue, gradlew clean
| Build > Clean | Build > Rebuild will just waste your time.
这里的大多数解决方案都是在黑暗中盲目刺伤.这是我发现的根本原因:
Most of the solutions here are blind stabbings in the dark. Here's what I found to be the root cause:
.iml
文件可能丢失(可能是因为我们删除了它),检查模块错误是否有.iml
..idea/modules.xml
是否有该模块的条目.iml
files may be missing (maybe because we deleted it),
check if the module erroring has .iml
..idea/modules.xml
has an entry for that module在同步时,我注意到 IDEA/AS 试图在 .idea/modules.xml
中放入一个新的重复条目,而已经有一个.当同步尝试重置内存中的模块时,此重复条目可能会被处理两次.
While syncing I noticed that IDEA/AS tries to put a new duplicate entry into .idea/modules.xml
while there's already one. This duplicate entry is probably disposed of twice while the sync tries to reset the modules in memory.
快速解决方案:为了使它工作,最简单的方法是删除 .idea/modules.xml
和 .iml
文件.另外可能值得删除 .idea/modules/
文件夹(如果存在).重新启动 Android Studio(无需清除缓存)并从 Gradle 视图或工具栏强制 Gradle 同步以重新创建文件.
Quick Solution: In order to make it work the easiest is to delete .idea/modules.xml
along with the .iml
files. Additionally may worth deleting .idea/modules/
folder if it exists. Restart Android Studio (no need to clear cache) and force a Gradle sync from Gradle view or toolbar to recreate the files.