【发布时间】:2023-03-14 14:55:01
【问题描述】:
更新后
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"
}
}
【问题讨论】:
-
似乎解决方案是更新-降级提到in here的谷歌服务。但是,如果能看到您的依赖项和 google 服务版本或任何比该错误更有用的信息,那就太好了。
-
@Mohsen 我试过了,但没用
-
怎么样:
classpath 'com.android.tools.build:gradle:3.2.0'和classpath 'com.google.gms:google-services:4.1.0'?请试试这个,让我知道会发生什么。 -
@Mohsen 我将 kotlin 的版本从
ext.kotlin_version = '1.2.71'降级到ext.kotlin_version = '1.2.61',现在它可以工作了。所以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" -
您在新版本的 AS 中使用旧的 Gradle + 旧的 google 服务。无论如何,很高兴听到它通过降级解决,但是,这很奇怪。我应该添加答案还是你会做?
标签: android android-studio gradle