Android Studio - Gradle同步失败:已被处理

15
更新到Android Studio 3.2 Beta 1后,我在两个不同的项目中都开始收到以下错误:
Gradle sync failed: Already disposed!

在更新到beta 1之前,Android Studio 3.2的各种预览版本都没有错误。 Android Studio 3.1.3没有错误。

我已经尝试了我能想到的一切(例如完全清理项目,包括所有生成的.gradle/.iml/.idea文件/文件夹,以及完全使Android Studio缓存无效并重新启动),但都没有成功。使用Gradle从命令行构建可以按预期工作。

这不是 Android Studio Gradle Already disposed Module 的重复。

编辑

事件日志显示

Unable to save plugin settings: The plugin org.jetbrains.android failed to save settings and has been disabled. Please restart Android Studio

在"IDE致命错误"窗口中,我看到以下异常:

'Gradle: backport-util-concurrent:backport-util-concurrent:3.1@jar' already disposed: --------------Creation trace: 
java.lang.Throwable
    at com.intellij.openapi.util.TraceableDisposable.<init>(TraceableDisposable.java:45)
    at com.intellij.openapi.roots.impl.libraries.LibraryImpl.<init>(LibraryImpl.java:103)
    at com.intellij.openapi.roots.impl.libraries.LibraryImpl.<init>(LibraryImpl.java:69)
    at com.intellij.openapi.roots.impl.libraries.LibraryTableBase$LibraryModel.readExternal(LibraryTableBase.java:327)
    at com.intellij.openapi.roots.impl.libraries.LibraryTableBase.loadState(LibraryTableBase.java:64)
    at com.intellij.openapi.roots.impl.libraries.LibraryTableBase.loadState(LibraryTableBase.java:30)
    at com.intellij.configurationStore.ComponentStoreImpl.doInitComponent(ComponentStoreImpl.kt:375)
    at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:331)
    at com.intellij.configurationStore.ComponentStoreImpl.initPersistenceStateComponent(ComponentStoreImpl.kt:121)
    at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:96)
    at com.intellij.openapi.components.impl.PlatformComponentManagerImpl.initializeComponent(PlatformComponentManagerImpl.java:54)

编辑2:

最近版本的Android Studio 3.2也出现了同样的问题。


你尝试过关闭并重新打开项目吗?有时更新无法正确更新项目结构。 - m0skit0
@m0skit0 是的,正如问题中提到的那样,我删除了所有生成的IntelliJ文件,重新启动并使Android Studio失效,然后尝试再次打开项目。 - friederbluemle
Android Studio 3.2的后续版本未能解决该问题,我在最新的3.3 canary 1版本中仍然遇到了同样的问题。 - friederbluemle
5个回答

15

事实证明,问题在于我试图打开一个项目目录,这是一个指向实际位置(在同一分区上)的符号链接。 Gradle(命令行方式)在符号链接的位置构建项目时没有任何问题,然而在Android Studio中打开它会导致上述晦涩且无用的错误。


2
我也遇到了同样的问题。浪费了很多时间清理Studio数据、插件和各种组合。即使是最新的Canary版本也没有帮助。感谢您指出这个问题! :) - fahadayaz
将AS指向实际目录而不是符号链接,这对我解决了问题。谢谢!你是否报告了这个问题?看起来像是一个bug。 - Aspiring Dev

14

简单解决方案

    1.Delete module folder and modules.xml file under .idea folder. 
    2.Close Android Studio
    3.Reopen and sync

1.Delete module folder and modules.xml file under .idea folder. 2.Close Android Studio 3.Reopen and sync Follow the steps not work, and you can try 1.Delete module folder and modules.xml file under .idea folder. 2.Close Android Studio 3. File -> Invalid Caches and Restart - Jeffery Ma
1
在.idea目录中,结构有些变化。对我有效的方法是:1. 删除modules.xml、libraries/和caches/ 2. 文件->无效缓存并重启 - Chris Watts

3
可能存在重复问题:
Android Studio 3.0 - 无法保存设置:保存设置失败。请重新启动Android Studio。Android Studio 3.0 - 无法保存设置:保存设置失败。请重新启动Android Studio 这对我有效:删除.idea文件夹。
1)转到 文件->设置->插件 禁用未加载的插件(即颜色为红色)@friederbluemle,这可能不适用于您。
2)启用一个插件,即Android支持。
3)在Android Studio中右键单击“app”目录(包含模块gradle.build文件),然后选择“在资源管理器中显示”——这将打开该目录。
4)退出Android Studio。退出所有Android Studio实例,以便您可以删除该目录中的.fold,.idea。
5)重新启动AS,您会注意到项目不会出现——您必须在出现的对话框窗口中进行选择。没关系。选择它,它会“重建”文件夹.idea。
6)转到 文件->设置->插件 启用任何和所有插件(如果有)。

感谢@Andrious Solutions提供详细的步骤 - 对我来说,问题不同,请查看我刚刚发布的答案。 - friederbluemle
6
删除所有的 .idea 目录后,我成功解决了这个错误。 - Ryan H.
2
只需要从项目视图中删除.idea文件夹,关闭项目(无需重启Android Studio),重新打开并在同步后进行重建。 - Jamal S

2

对我有用的方法是打开Android Studio的文件(File)选项,然后选择无效/重启(Invalidate/Restart)选项。


1

以下是对我有效的步骤:

  1. 删除 .idea 文件夹
  2. 关闭 Android Studio
  3. 重新打开 Android Studio 并允许其重新同步你的项目。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接