【问题标题】:Android Studio - Gradle sync failed: Already disposedAndroid Studio - Gradle 同步失败:已处理
【发布时间】:2018-12-03 04:47:45
【问题描述】:

更新到 Android Studio 3.2 Beta 1 后,我开始在两个不同的项目中收到以下错误:

Gradle sync failed: Already disposed!

Android Studio 3.1.3 没有错误,更新到 beta 1 之前的各种金丝雀版本的 Android Studio 3.2 也没有错误。

我已经尝试了所有我能想到的方法(例如完全清理项目,包括所有生成的 .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)

EDIT2:

Android Studio 3.2 的更新版本也有同样的问题。

【问题讨论】:

  • 您是否尝试关闭并重新打开该项目?有时更新无法相应地更新项目结构。
  • @m0skit0 是的,正如问题中提到的,我删除了所有生成的 IntelliJ 文件,重新启动并使 Android Studio 失效,并尝试再次打开项目。
  • Android Studio 3.2 的更高版本没有解决这个问题,我在最新的 3.3 canary 1 版本中仍然遇到同样的问题。

标签: android linux android-studio gradle


【解决方案1】:

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

【讨论】:

  • 我遇到了同样的问题。浪费了很多时间来清理 Studio 数据和插件以及事物的组合。即使是最新的 Canary 也无济于事。感谢您指出问题! :)
  • 指向实际目录而不是符号链接为我解决了这个问题。谢谢!你是不是碰巧报告了这个?看起来像一个错误。
【解决方案2】:

简单的解决方案

    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 按步骤不行,可以试试1.Delete module folder and modules.xml file under .idea folder. 2.Close Android Studio 3. File -&gt; Invalid Caches and Restart
  • .idea 目录中的结构发生了一些变化。对我有用的是1. Delete modules.xml, libraries/, and caches/2. File -&gt; Invalidate Caches and Restart
【解决方案3】:

可能的重复问题:
Android Studio 3.0 - 无法保存设置:无法保存设置。请重启Android StudioAndroid Studio 3.0 - Unable to save settings: Failed to save settings. Please restart Android Studio

这对我有用:删除 .idea 文件夹。

1) 转到文件--> 设置-->插件禁用任何未加载的插件(即红色)@friederbluemle 这可能不适用于您。

2) 启用一个插件,Android 支持

3) 在 Android Studio 中右键单击您的“应用”目录(包含您的模块 gradle.build 文件)并选择“在资源管理器中显示”——这将打开该目录。

4) 退出 Android Studio。退出所有 Android Studio 实例,然后删除该目录中的折叠 .idea。

5) 重新启动 AS,您会注意到项目不会出现 - 您必须在出现的对话框窗口中进行选择。没关系。选择它,它将“重建”文件夹 .idea。

6) 转到文件--> 设置-->插件启用任何和所有插件(如果有)。

【讨论】:

  • 感谢@Andrious Solutions 的详细步骤 - 对我来说这是一个不同的问题,请参阅我刚刚发布的答案。
  • 删除所有.idea 目录为我消除了这个错误。
  • 只需删除项目中的.idea文件夹(切换到项目视图),关闭项目(无需重新启动android studio)重新打开它并在同步后重建
【解决方案4】:

对我有用的是 Android Studio FileInvalidate/Restart 选项。

【讨论】:

    【解决方案5】:

    对我有用的如下

    1. 删除.idea文件夹
    2. 关闭 Android Studio
    3. 重新打开 Android Studio 并让它全面同步您的项目。

    【讨论】:

      猜你喜欢
      • 2016-05-18
      • 2023-04-09
      • 2017-11-07
      • 2019-06-07
      • 1970-01-01
      • 2019-01-18
      • 1970-01-01
      • 2016-02-04
      • 2014-07-03
      相关资源
      最近更新 更多