1

After updating to

    Android Studio 3.2.1
    Build #AI-181.5540.7.32.5056338, built on October 9, 2018
    JRE: 1.8.0_152-release-1136-b06 amd64
    JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
    Windows 7 6.1

The error occurs:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Cannot change dependencies of configuration ':app:qaCompile' after it has been included in dependency resolution.

build.gradle

apply plugin: 'kotlin'
apply plugin: 'base'
apply plugin: 'maven'
buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        //region realm
        maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
        //endregion
    }
    dependencies {
        //region google()
        classpath 'com.android.tools.build:gradle:3.1.4'
        //endregion
        //region jcenter()
        classpath 'com.google.gms:google-services:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.orhanobut.tracklytics:tracklytics-plugin:2.0.0'
        //endregion
        //region maven { url 'https://maven.fabric.io/public' }
        //to check fabric gradle ver
        //https://s3.amazonaws.com/fabric-artifacts/public/io/fabric/tools/gradle/maven-metadata.xml
        classpath 'io.fabric.tools:gradle:1.+'
        //endregion
        //region realm
        classpath "io.realm:realm-gradle-plugin:5.4.2"
        //endregion
    }
}

allprojects {

    repositories {
        mavenLocal()
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
NickUnuchek
  • 11,794
  • 12
  • 98
  • 138
  • Seems like the solution is to update-downgrade the google services which mentioned [in here](https://stackoverflow.com/questions/50158947/cannot-change-dependencies-of-configuration-appapi-after-it-has-been-include). But, that would be great to see your dependencies and google services version or anything helpful than that error. – ʍѳђઽ૯ท Oct 15 '18 at 08:10
  • @Mohsen I tried , but doesnt work – NickUnuchek Oct 15 '18 at 08:14
  • How about: `classpath 'com.android.tools.build:gradle:3.2.0'` and `classpath 'com.google.gms:google-services:4.1.0'` ? Please try this and let me know what happens. – ʍѳђઽ૯ท Oct 15 '18 at 08:16
  • @Mohsen `Minimum supported Gradle version is 4.6. Current version is 4.4. Please fix the project's Gradle settings.` And after update to 4.6 , the error occurs `Cannot change dependencies of configuration ':app:qaCompile' after it has been included in dependency resolution. ` – NickUnuchek Oct 15 '18 at 08:22
  • I'm suspecting about this part: `io.fabric.tools:gradle:1.+` Use latest version: [`1.21.5`](https://s3.amazonaws.com/fabric-artifacts/public/io/fabric/tools/gradle/maven-metadata.xml) and this can be helpful I hope: https://stackoverflow.com/questions/33878465/cannot-change-dependencies-of-configuration-after-enabling-instant-run – ʍѳђઽ૯ท Oct 15 '18 at 08:35
  • 1
    @Mohsen I downgrade version of kotlin from `ext.kotlin_version = '1.2.71'` to `ext.kotlin_version = '1.2.61'`, now it works. So `ext.kotlin_version = '1.2.61'` , `classpath 'com.android.tools.build:gradle:3.2.1' `, `classpath 'com.google.gms:google-services:4.1.0'` , `BuildToolsVersion = "28.0.3"` – NickUnuchek Oct 15 '18 at 08:46
  • 1
    You were using older Gradle + old google services with the new version of AS. Anyways, it's good to hear it solved with downgrading, however, that is pretty weird. Should I add an answer or you'll do? – ʍѳђઽ૯ท Oct 15 '18 at 08:49

1 Answers1

0

Downgrading the version of kotlin from ext.kotlin_version = '1.2.71' to ext.kotlin_version = '1.2.61' might help.

Also, updated the Gradle and google services to the latest stable version.

So in build.gradle:

apply plugin: 'kotlin'
apply plugin: 'base'
apply plugin: 'maven'
buildscript {
    ext.kotlin_version = '1.2.61'
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        //region realm
        maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
        //endregion
    }
    dependencies {
        //region google()
        classpath 'com.android.tools.build:gradle:3.2.1'
        //endregion
        //region jcenter()
        classpath 'com.google.gms:google-services:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.orhanobut.tracklytics:tracklytics-plugin:2.0.0'
        //endregion
        //region maven { url 'https://maven.fabric.io/public' }
        //to check fabric gradle ver
        //https://s3.amazonaws.com/fabric-artifacts/public/io/fabric/tools/gradle/maven-metadata.xml
        classpath 'io.fabric.tools:gradle:1.+'
        //endregion
        //region realm
        classpath "io.realm:realm-gradle-plugin:5.4.2"
        //endregion
    }
}

allprojects {

    repositories {
        mavenLocal()
        google()
        jcenter()
        mavenCentral()


        maven { url "https://jitpack.io" }
    }

}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

app/build.gradle:

buildToolsVersion = "28.0.3"
supportLibVer = '28.0.0'

However, using + is not recommended when adding a library or class path in Android Studio. Like I said, it's better to include the latest version.

So, instead of io.fabric.tools:gradle:1.+ Use latest version: 1.21.5.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108