Android Studio – Gradle sync failed: Already disposed

androidandroid-studiogradlelinux

After updating to Android Studio 3.2 Beta 1, I started getting the following error for two different projects:

Gradle sync failed: Already disposed!

There is no error with Android Studio 3.1.3, and there was no error with various canary versions of Android Studio 3.2 before updating to beta 1.

I already tried everything I can think of (e.g. complete cleaning of project, including all generated .gradle/.iml/.idea files/folders, as well as a complete invalidate cache and restart of Android Studio) without success. The build works as expected from command line using Gradle.

This is not a duplicate of Android Studio Gradle Already disposed Module

EDIT

The event log is showing

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

In the "IDE Fatal Errors" window, I am seeing the following exception:

'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:

More recent version of Android Studio 3.2 are having the same issue.

Best Answer

As it turned out, the problem was that I was trying to open a project directory that was a symlink to the actual location (on the same partition). Gradle (on command line) had no issues building the project from the symlinked location, however, opening it in Android Studio resulted in the obscure and non helpful error described above.