李老栓
李老栓

Reputation: 83

Circular dependency between the following tasks in gradle

I'm running my project in AndroidStudio 3.2, but there is an error

FAILURE: Build failed with an exception.

* What went wrong:
Circular dependency between the following tasks:
:app:checkManifestChangesDebug
\--- :app:instantRunMainApkResourcesDebug
     \--- :app:transformClassesAndDexWithShrinkResForDebug
          \--- :app:transformDexArchiveWithDexMergerForDebug
               +--- :app:preColdswapDebug
               |    \--- :app:incrementalDebugTasks
               |         +--- :app:transformClassesAndClassesEnhancedWithInstantReloadDexForDebug
               |         |    \--- :app:transformClassesWithInstantRunForDebug
               |         |         \--- :app:checkManifestChangesDebug (*)
               |         \--- :app:transformClassesWithInstantRunForDebug (*)
               \--- :app:transformClassesWithDexBuilderForDebug
                    +--- :app:preColdswapDebug (*)
                    \--- :app:transformClassesWithInstantRunForDebug (*)

(*) - details omitted (listed previously)

I can still generate APKs manually, but the "Run" button doesn't work.

How can I solve the issue?

Upvotes: 8

Views: 18396

Answers (2)

depau
depau

Reputation: 464

As noted by @hocine-b in the comments, this may happen if you enable shrinkResources in ProGuard.

It only occurs when Instant Run is enabled, i.e. in debug builds when you press the "Run" button.

You can fix it by only shrinking resources in release builds, for example, in your module's build.gradle:

android {
    buildTypes {
        debug {
            minifyEnabled true
            shrinkResources false  // Avoid conflicts with Instant Run 
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Upvotes: 8

Ibrahim
Ibrahim

Reputation: 172

Disable instant run from settings

Settings > search for instant run > uncheck "Enable Instant Run to hot swap code/resource changes on display"

Upvotes: 11

Related Questions