使用firebase-analytics时重复的jar条目:16.0.5

时间:2018-11-07 05:12:36

标签: android firebase firebase-analytics

广告17.1.1(developers.google.com/android/guides/releases)中的官方修正


将firebase-analytics的版本从16.0.4更新为16.0.5之后 项目无法构建版本aab / apk,并显示错误消息Duplicate jar entry [com/google/android/gms/internal/measurement/zzdz.class]

Android Studio 3.2.1

应用程序的build.gradle

    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.google.firebase:firebase-analytics:16.0.5'
    implementation 'com.google.firebase:firebase-ads:17.1.0'
    implementation 'com.google.firebase:firebase-perf:16.2.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'

项目build.gradle

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
        classpath 'io.fabric.tools:gradle:1.26.1'
    }

错误

Caused by: java.io.IOException: Can't write [MASKED\app\build\intermediates\transforms\proguard\release\0.jar] (Can't read [MASKED\app\build\intermediates\transforms\FirebasePerformancePlugin\release\21(;;;;;;;**.class)] (Can't read [com] (Can't read [google] (Can't read [android] (Can't read [gms] (Can't read [internal] (Can't read [measurement] (Can't read [zzdz.class] (Duplicate jar entry [com/google/android/gms/internal/measurement/zzdz.class])))))))))    at proguard.OutputWriter.writeOutput(OutputWriter.java:202)     at proguard.OutputWriter.execute(OutputWriter.java:89)  at proguard.ProGuard.writeOutput(ProGuard.java:515)     at proguard.ProGuard.execute(ProGuard.java:210)     at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:64)  at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:262)    at com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:65)     at com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:176)     at com.android.builder.tasks.Job.runTask(Job.java:47)   at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)   at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:282)  ... 1 more

在发布修复程序之前有任何解决方法?

3 个答案:

答案 0 :(得分:2)

使用了gradlew :app:dependencies,发现某些依赖项没有使用最新版本。

手动添加以下依赖项以覆盖加载的版本可以解决该问题。

implementation 'com.google.android.gms:play-services-measurement-sdk-api:16.0.3'
implementation 'com.google.android.gms:play-services-basement:16.1.0'

答案 1 :(得分:0)

一旦遇到此问题,请尝试将Google Play服务版本更新为最新版本,并更新您正在使用的所有Firebase库。 从Android Studio 3.2.1开始,以下是最新的内容:

 dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

答案 2 :(得分:0)

这是简单的解决方案,

Google已解决此问题,您需要做的就是将ads gradle版本更新为17.1.1,这将解决firebase-core:16.0.5的问题,添加以下几行即可解决该问题

implementation 'com.google.firebase:firebase-ads:17.1.1'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
implementation 'com.google.firebase:firebase-core:16.0.5'