更新Gradle依赖项后生成错误。嫌疑人1是火力发源地

时间:2018-11-08 13:18:19

标签: java android firebase gradle

我有一个构建良好的应用程序,但是当我尝试更新某些Gradle依赖项时就开始失败,而主要的怀疑对象是firebase。

这是我得到的错误:

  

原因:   com.android.builder.multidex.D8MainDexList $ MainDexListException:   com.android.tools.r8.errors.CompilationError:程序类型已经   礼物:com.google.android.gms.internal.measurement.zzdz

这是我项目的git diff,显示了Gradle文件中的差异:

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依赖关系更新到最新版本似乎是这样。导致我的项目出现问题!使用旧版本,它可以正常运行。

这些是所涉及的Gradle脚本的内容(我已经用'com.myapp.id'代替了实际的applicationId)

:核心

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

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

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相关的最相关的部分是顶部。下面我只显示它与核心模块的关系。

enter image description here

这是一个libGDX游戏,我正在使用IntelliJ Idea,尽管这无关紧要,因为我在命令行中使用./gradlew构建时遇到了这些错误。


编辑:我按照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依赖于导致错误的较旧版本的库。

看看这些依赖项输出:

这是我使用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)

这对于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(*)”解释这些输出,我认为是问题的原因。

1 个答案:

答案 0 :(得分:2)

好吧,由于所有评论都移到了聊天中,并且我的临时解决方法也在那里,所以现在是:

您的错误消息将我的搜索带到了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:程序类型已经   目前:___

该错误表明某个地方存在重复的依赖关系,该依赖关系运行于两个不同的版本。然后的目标是运行./gradlew app:dependencies来生成依赖项的树/列表以寻找com.google.android.gms.internal.measurement.zzdz。问题在于,这是一个模糊的内部私有包,因此无法在列表中直接找到它,但是关键字measurement是一个提示。

这使我注意到coreads具有相似的内容:play-services-measurement-api:[16.0.3] -> 16.0.3 (*)play-services-measurement-sdk-api:16.0.2。通过测试,我发现了两种解决方法:

  1. com.google.firebase:firebase-core:16.0.5降级为16.0.4
  2. exclude group: 'com.google.android.gms', module: 'play-services-measurement-sdk-api'添加到ads依赖项

第一个选项可能更安全,因为重新运行./gradlew app:dependencies表明play-services-measurement-apiplay-services-measurement-sdk-api现在都是16.0.2

我敢肯定Google / Firebase知道这一点,因为我确实在https://issuetracker.google.com/issues/119213680上找到了另一个提及。翻译是:该错误与zzdz类重复,存在的过渡zzdz类的状态如下。请注意,play-services-measurement-sdk-api可能会与其他Firebase / GMS库发生问题。应该有一个即将发布的修复程序来对其进行更新。

*请注意,即使切换到"com.google.firebase:firebase-ads:17.1.0"仍然会导致此错误。