Error:Cannot change dependencies of configuration ':app:_debugAnnotationProcessor' after it has been resolved

21,008

Solution 1

I got it when trying to add a dependency to "com.android.support.constraint:constraint-layout:1.0.0-beta4" for an android training class.

I managed to get past it and it did involve Jack, as @Scott suspected.

Got past it by:

  1. commenting out the added dependency, the jackOptions enable true block, and the compileOptions block, where I had it compatible with 1.8.
  2. Sync/Clean/Rebuild Gradle (whichever it is, I'm still learning)
  3. Uncomment the added dependency, sync/rebuild gradle again
  4. Uncomment the jackOptions and compileOptions blocks, sync/rebuild gradle again

At that point, it worked for me.

Solution 2

Add it to app build.gradle or project build.module:

repositories {
    maven {
        url 'https://maven.google.com'
    }
}

I get this problem when I add 'constraint-layout' dependency and I find out answer in ofical manual: https://developer.android.com/training/constraint-layout/index.html I think it will help you!

Solution 3

After hours of trying everything, this worked for me -> Upgrade com.google.gms:google-services to latest version. Case : added

dataBinding {
   enabled = true
}

Solution : In project gradle classpath changed

'com.google.gms:google-services:3.3.1'

to

'com.google.gms:google-services:4.0.1' (latest version)

Solution 4

I upgraded gradle and a google-play-services lib and didn't realize that you are apparently required to remove apply plugin: 'com.google.gms.google-services' at the end of app module's build.gradle. Removing it solved this for me.

The docs were a little misleading. Removing apply plugin: 'com.google.gms.google-services' did indeed solve this problem, but the line is still required for Firebase to work actually. After some more playing around, I noticed that also removing the dataBinding{enabled true} made the error go away. But again, also this is not a solution. In the end I had to downgrade to com.android.tools.build:gradle:3.0.0 - which again is obviously not a solution because you are missing out on e.g. InstantRun, but at least it builds. The whole issue was introduced after an update to Android Studio 3.1.2, so I assume that downgrading again would solve it.

Share:
21,008
Aman Jain
Author by

Aman Jain

Updated on July 14, 2022

Comments

  • Aman Jain
    Aman Jain over 1 year

    Gradle Project Refresh Failed

    After I added KenBurnsView Library to build.gradle on app level. When I try to sync the gradle it failed.

    build.gradle (app level)

    apply plugin: 'com.android.application'
    
    android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.sample.ac"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0_dev"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    
    repositories {
        jcenter()
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    }
    
    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    
    //ButterKnife for view injector
    compile 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    
    // EventBus for passing data between activities and fragments
    compile 'org.greenrobot:eventbus:3.0.0'
    
    //Material Loading Circular Progress Bar with white background
    compile 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
    
    //GSON for parsing JSON into Java Object and vice versa
    compile 'com.google.code.gson:gson:2.6.2'
    
    //For Image Loading from network
    compile 'com.github.bumptech.glide:glide:3.7.0'
    
    //SLiding up Panel Layout for Music Player
    compile 'com.sothree.slidinguppanel:library:3.3.0'
    
    //For Network Calling
    compile 'com.mcxiaoke.volley:library:1.0.19'
    
    //ViewPagerIndicator
    compile 'com.romandanylyk:pageindicatorview:0.0.7'
    
    //Google Play Services
    compile 'com.google.android.gms:play-services-auth:10.0.0'
    compile 'com.google.android.gms:play-services-plus:10.0.0'
    compile 'com.google.android.gms:play-services-identity:10.0.0'
    compile 'com.google.android.gms:play-services-base:10.0.0'
    compile 'com.google.android.gms:play-services-location:10.0.0'
    compile 'com.google.android.gms:play-services-maps:10.0.0'
    compile 'com.google.android.gms:play-services-gcm:10.0.0'
    
    //Ken Burns Effect for Image Background
    compile 'com.flaviofaria:kenburnsview:1.0.7'
    
    //Material Search View
    // compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile project(':searchlibrary')
    
    testCompile 'junit:junit:4.12'
    
    }
    apply plugin: 'com.google.gms.google-services'
    

    build.gradle (project level)

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.google.gms:google-services:3.0.0'
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    }
    
    allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
    }
    
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    
  • kdawg
    kdawg almost 7 years
    That I can't say, unfortunately. I'm not familiar with what's going on behind the scenes.
  • Mark
    Mark almost 7 years
    I was able to get past the problem by simply removing jackOptions and compileOptions from the app level Gradle file, sync/build then add back in and sync/build. Jack does offer some good features, but I'm getting tired of it being temperamental especially with libraries like Dagger 2 (for which I have include the complete Guava library otherwise I receive NoMethodFound error when compiling).
  • natronite
    natronite over 5 years
    Is this documented anywhere?