将配置的依赖关系包含在Android Studio 3.2.1的依赖关系解析后,无法更改

时间:2018-10-15 08:07:59

标签: android android-studio gradle

更新为

    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

发生错误:

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"
    }
}

1 个答案:

答案 0 :(得分:0)

将kotlin的版本从ext.kotlin_version = '1.2.71'降级到ext.kotlin_version = '1.2.61'可能会有所帮助。

另外,将Gradle和google服务更新为最新的稳定版本。

所以在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'

但是,在Android Studio中添加库或类路径时,不建议使用+。就像我说的,最好包含最新版本。

因此,不要使用io.fabric.tools:gradle:1.+的最新版本:1.21.5