【问题标题】:Firebase duplicate classes error after update更新后 Firebase 重复类错误
【发布时间】:2020-12-01 04:09:34
【问题描述】:

一切都适用于 com.google.firebase:firebase-core:16.0.4 版本,但有一个较新的版本,当我在 gradle 中将其更新为 com.google.firebase:firebase-core:16.0.5 然后运行我的应用程序时出现此错误

   org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\User\AndroidStudioProjects\AppName\app\build\intermediates\transforms\dexBuilder\debug\0.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
    Program type already present: com.google.android.gms.internal.measurement.zzdz

这是我的 gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.app.test"
        vectorDrawables.useSupportLibrary = true
        minSdkVersion 17
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation "com.android.support:support-compat:28.0.0"
    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.android.support:design:28.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-ads:17.0.0'
    implementation 'com.google.firebase:firebase-firestore:17.1.2'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'

【问题讨论】:

    标签: android firebase


    【解决方案1】:

    最新的firebase-core是16.0.4版本,可以通过以下链接查看各个依赖的最新版本:

    https://firebase.google.com/support/release-notes/android

    【讨论】:

    • 你说得对,这不是我的 android studio 告诉我的,我想我已经习惯了甚至不仔细检查 Link
    • 我明白了.. 它仍未在发行说明和 firebase 网站的入门部分中列出。它列在 google maven 存储库中(可以签入此链接并导航到 com.google.firebase dl.google.com/dl/android/maven2/index.html),这意味着他们确实发布了它,但最好继续使用 16.0.4,直到他们将其添加到发布说明中网站。
    • 我不得不从 17.0.0 回到 play-services-ads:16.0.0。我的其余依赖项都是最新的;所以没有 lint 警告,是的 16.0.5。希望这会为人们节省很多时间!
    【解决方案2】:

    修复:将其插入app/build.gradle

    适用于对原生 firebase v25.12.0 做出反应,因此请确保对此进行更新。

    插入dependencies部分

    implementation 'com.google.android.gms:play-services-vision:20.1.1'
    implementation 'com.google.android.gms:play-services-vision-common:19.1.1'
    implementation 'com.google.firebase:firebase-ml-vision-image-label-model:20.0.2'
    implementation 'com.google.android.gms:play-services-vision-face-contour-internal:16.0.3'
    implementation 'com.google.android.gms:play-services-vision-image-labeling-internal:16.0.5'
    implementation 'com.google.android.gms:play-services-vision-image-label:18.0.5'
    implementation 'com.google.firebase:firebase-ml-vision-face-model:20.0.2'
    implementation 'com.google.firebase:firebase-ml-model-interpreter:22.0.4'
    

    参考:https://github.com/invertase/react-native-firebase/commit/dc4f57a952a7076a48a224087c9a8e7cdeaf4afc#diff-8a85188c69631f3ee1d3b09e01cdfcffae515432e9efdfb74683b880a8902172

    【讨论】:

      猜你喜欢
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 2019-08-13
      • 2019-09-30
      • 2014-08-22
      • 1970-01-01
      • 1970-01-01
      • 2018-12-21
      相关资源
      最近更新 更多