更新Gradle依赖项后生成错误.嫌疑犯#1是火力发源地 [英] Build errors after updating Gradle dependencies. Suspect #1 is firebase
问题描述
我有一个构建良好的应用程序,但是当我尝试更新某些Gradle依赖项时就开始失败,而主要的疑虑是firebase.
I have an app that builds just fine, but starts failing as soon as I try to update some Gradle dependencies, whereas the main suspect is firebase.
这是我得到的错误:
起因:com.android.builder.multidex.D8MainDexList $ MainDexListException:com.android.tools.r8.errors.CompilationError:程序类型已经礼物:com.google.android.gms.internal.measurement.zzdz
Caused by: com.android.builder.multidex.D8MainDexList$MainDexListException: com.android.tools.r8.errors.CompilationError: Program type already present: com.google.android.gms.internal.measurement.zzdz
这是我项目的git diff,显示了Gradle文件中的差异:
And this is the git diff for my project, showing the differences in the Gradle files:
diff --git a/android/build.gradle b/android/build.gradle
index 9f63f745..08fda2eb 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -81,8 +81,8 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation fileTree(include: ['*.jar'], dir: 'libs')
diff --git a/android_common/build.gradle b/android_common/build.gradle
index f8224509..3a5d45e1 100644
--- a/android_common/build.gradle
+++ b/android_common/build.gradle
@@ -19,7 +19,7 @@ android {
androidTest.setRoot('tests')
}
defaultConfig {
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -65,8 +65,8 @@ dependencies {
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
diff --git a/android_instant_feature/build.gradle b/android_instant_feature/build.gradle
index 30431c11..17c4ef27 100644
--- a/android_instant_feature/build.gradle
+++ b/android_instant_feature/build.gradle
@@ -18,7 +18,7 @@ android {
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
@@ -77,8 +77,8 @@ dependencies {
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation 'com.google.android.gms:play-services-instantapps:16.0.0'
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation 'com.google.android.gms:play-services-instantapps:16.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
diff --git a/core/build.gradle b/core/build.gradle
index dd2640cf..5694a1da 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -15,7 +15,7 @@ dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
- compile 'com.google.code.gson:gson:2.8.2'
+ compile 'com.google.code.gson:gson:2.8.5'
compile group: 'org.apache.commons', name: 'commons-text', version: '1.2'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
compile group: 'org.jetbrains', name: 'annotations', version: '16.0.1'
@@ -23,7 +23,7 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
testCompile 'junit:junit:4.12'
- testCompile 'org.mockito:mockito-core:2.7.22'
+ testCompile 'org.mockito:mockito-core:2.8.9'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '1.7.3'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.7.3'
}
请注意,其中某些更改(如minSDKVersion)可以作为错误源丢弃.似乎最有可能与Firebase有关.为什么?好吧,在Stackoverflow中还存在其他问题,但是所有这些中提出的解决方案都是将firebase依赖关系更新到最新版本,但是将firebase依赖关系更新到最新版本似乎是这样.导致我的项目出现问题!使用旧版本,它就可以很好地构建.
Please, note that some of these changes like the minSDKVersion can be discarded as the source of the error. It seems most likely it is related to firebase. Why? Well, among other things there are other questions in Stackoverflow in which that's the case, however the solution proposed in all of these is to update firebase dependencies to last version, but updating firebase dependencies to last version is what it seems to be causing the problem in my project! With the old versions it just builds fine.
这些是所涉及的Gradle脚本的内容(我已经用'com.myapp.id'代替了实际的applicationId)
These are the contents of the Gradle scripts involved (I have replaced the actual applicationId with 'com.myapp.id')
:核心
apply plugin: "java"
targetCompatibility = 1.8
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = ["src/main"]
sourceSets.test.java.srcDirs = ["src/test"]
dependencies {
compile 'commons-io:commons-io:2.6'
compile 'commons-codec:commons-codec:1.11'
compile 'com.google.code.gson:gson:2.8.5'
compile 'org.apache.commons:commons-text:1.2'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'org.jetbrains:annotations:16.0.1'
compile "com.badlogicgames.gdx:gdx:1.9.9-SNAPSHOT"
compile "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.8.9'
testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
testCompile 'org.powermock:powermock-module-junit4:1.7.3'
}
repositories {
mavenCentral()
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
:android_common
:android_common
apply plugin: "com.android.feature"
configurations { natives }
android {
baseFeature true
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
androidTest.setRoot('tests')
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets {
all {
manifest.srcFile "AndroidManifest.xml"
}
}
multiDexEnabled true
}
buildTypes {
release {
setMinifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.2'
lintOptions {
abortOnError false
}
dexOptions {
jumboMode true
}
}
dependencies {
application project(':android')
feature project(':android_instant_feature')
api project(':core')
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.guava:guava:24.0-android'
}
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
:android
apply plugin: "com.android.application"
apply plugin: 'io.fabric' // Needed by crashlytics. DO NOT REMOVE.
android {
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
androidTest.setRoot('tests')
}
defaultConfig {
applicationId "com.myapp.id"
versionCode 4032
versionName "4.1.2.1"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
dexOptions {
jumboMode true
}
// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}
task importPuzzles(type: Exec) {
// TODO
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}
dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
:android_instant_feature
:android_instant_feature
apply plugin: "com.android.feature"
android {
// baseFeature true
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
dexOptions {
jumboMode true
}
// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
// minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}
dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation 'com.google.android.gms:play-services-instantapps:16.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
最后,这是我项目的结构.与android相关的最相关的部分是顶部.下面我仅显示它与核心模块的关系.
Finally, this is the structure of my project. The most relevant part as it's android related is the one on the top. Below I just show how it's related to the core module.
这是一个libGDX游戏,我正在与IntelliJ Idea一起工作,尽管这无关紧要,因为我在命令行中使用./gradlew构建时遇到了这些错误.
This is a libGDX game and I'm working with IntelliJ Idea, though this is not relevant since I'm getting these errors with ./gradlew build in the command line.
按照TWL的建议,我将firebase-core从16.0.5降级到16.0.4,并且可以正常工作,因此,我认为这是可以接受的解决方法,至少在firebase家伙发布firebase-core 16.0.6左右的时候实际上与firebase-ads 17.0.0兼容.问题似乎很有效,因为firebase-ads 17.0.0依赖于导致错误的较旧版本的库.
I downgraded firebase-core from 16.0.5 to 16.0.4 as suggested by TWL and it worked, so I think it's an acceptable workaround, at least while the firebase guys release a firebase-core 16.0.6 or so actually compatible with firebase-ads 17.0.0. The problem seems to be effectively that firebase-ads 17.0.0 relies on a older version of the library that's causing the error.
看看这些依赖项输出:
这是我使用firebase-core 16.0.4的结果:
This is what I get with firebase-core 16.0.4:
$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [0s]
> :android_common:dependencies
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
...(依次类推,全部都是16.0.3)
... (and so on, all 16.0.3 straight forward)
对于firebase-core 16.0.5:
And this for firebase-core 16.0.5:
$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [1s]
> :android_common:dependencies > Resolve dependencies of :android_common:releaseUnitTestRuntimeClasspath
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | \--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
如您所见,尽管我不太精通,但仍有一些条目,例如"com.google.android.gms:play-services-measurement-base:16.0.3-> 16.0.4(*)"解释这些输出,我认为是造成此问题的原因.
As you see, there are some entries like "com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)" that, despite I'm not proficient on interpreting these outputs, I think are the cause of the issue.
推荐答案
好吧,由于所有评论都移到了聊天中,并且我的临时解决方法也在那里,所以这里是:
您的错误消息将我的搜索带到了com.android.tools.r8.errors.CompilationError:程序类型已存在:androidx.annotation.AnimRes
Your error message brought my searching to com.android.tools.r8.errors.CompilationError: Program type already present: androidx.annotation.AnimRes
起因:com.android.builder.multidex.D8MainDexList $ MainDexListException:com.android.tools.r8.errors.CompilationError:程序类型已经目前:___
Caused by: com.android.builder.multidex.D8MainDexList$MainDexListException: com.android.tools.r8.errors.CompilationError: Program type already present: ___
该错误表明某个地方存在重复的依赖关系,该依赖关系运行于两个不同的版本.然后的目标是运行 ./gradlew app:dependencies
以生成依赖关系的树/列表以查找 com.google.android.gms.internal.measurement.zzdz
.问题在于这是一个模糊的内部私有包,因此不会直接在列表中找到,但是关键字 measurement
是一个提示.
That error suggests there is a duplicate dependency somewhere that is running off two different versions. Then the goal is to run ./gradlew app:dependencies
to produce a tree/list of the dependencies to look for com.google.android.gms.internal.measurement.zzdz
. The problem is that this is obfuscated and an internal private package, so it won't be directly found in the list, but the keyword measurement
is a hint.
这使我注意到 core
和 ads
具有相似的内容: play-services-measurement-api:[16.0.3]->16.0.3(*)
和 play-services-measurement-sdk-api:16.0.2
.通过测试,我发现了两种解决方法:
This led me to notice that core
and ads
have something similar: play-services-measurement-api:[16.0.3] -> 16.0.3 (*)
and play-services-measurement-sdk-api:16.0.2
. With testing, I found two workarounds:
- 将
com.google.firebase:firebase-core:16.0.5
降级为16.0.4
- 将
排除组:'com.google.android.gms',模块:'play-services-measurement-sdk-api'
添加到ads
依赖项
- downgrade
com.google.firebase:firebase-core:16.0.5
to16.0.4
- add
exclude group: 'com.google.android.gms', module: 'play-services-measurement-sdk-api'
to theads
dependency
第一个选项可能更安全,因为重新运行 ./gradlew app:dependencies
显示 play-services-measurement-api
和 play-services-measurement-sdk-api
现在都是 16.0.2
.
First option is probably safer to do, since a re-run of ./gradlew app:dependencies
showed that play-services-measurement-api
and play-services-measurement-sdk-api
were both now 16.0.2
.
而且我确定Google/Firebase知道了这一点,因为我确实在 https://issuetracker.google.com/issues/119213680 的翻译是:该错误是zzdz类的重复,zzdz类的存在状态的转换如下.因此请注意, play-services-measurement-sdk-api
可能会遇到其他Firebase/GMS库的问题.应该有一个即将发布的修复程序来对其进行更新.
And I'm sure Google/Firebase is aware of this since I did just find another mention of it at https://issuetracker.google.com/issues/119213680 The translation is: The error is duplicate of class zzdz, the transition of the existence status of zzdz class is as follows. So beware that play-services-measurement-sdk-api
can run into issues with other Firebase/GMS libraries. There should be an upcoming fix to update it.
*请注意,即使切换到"com.google.firebase:firebase-ads:17.1.0"
仍会导致此错误.
*Note that even switching to "com.google.firebase:firebase-ads:17.1.0"
will still cause this error.
这篇关于更新Gradle依赖项后生成错误.嫌疑犯#1是火力发源地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!