java.util.zip.ZipException:重复条目:android/arch/lifecycle/LiveData$1.class

java.util.zip.ZipException: duplicate entry: android/arch/lifecycle/LiveData$1.class

好吧,我可以 运行 我的应用程序在设备上处于调试模式,没有问题,但如果我想生成签名的 apk,它会出现此错误

Error:Execution failed for task ':app:transformDexWithDexForRelease'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/arch/lifecycle/LiveData;

什么是"LiveData.class" 其实我不懂

这是我的依赖项:

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])

    //arayüz
    implementation  'com.android.support:appcompat-v7:27.1.0'
    implementation  'com.android.support:palette-v7:27.1.0'
    implementation  'com.android.support:cardview-v7:27.1.0'
    implementation  'com.android.support:recyclerview-v7:27.1.0'
    implementation  'com.android.support:support-v4:27.1.0'
    implementation  'com.android.support:design:27.1.0'
    implementation  'com.android.support.constraint:constraint-layout:1.0.2'

    //firebase
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.firebaseui:firebase-ui-storage:3.2.1'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.firebase:firebase-config:11.8.0'
    implementation 'com.firebaseui:firebase-ui-database:3.0.0'

    //metariel View Pager
    implementation 'com.github.florent37:materialviewpager:1.2.3'

    //Glide
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}
apply plugin: 'com.google.gms.google-services'

我从两天前就开始面对这个问题,现在我今天解决了 这些是步骤

首先在您的应用级别 gradle 文件中尝试此操作

 implementation('com.github.bumptech.glide:glide:4.6.1') {
    exclude group: 'com.android.support'
}`

如果它没有解决尝试记录依赖 运行 这个命令

./gradlew -q dependencies app:dependencies --configuration compile

在您的 android 工作室的终端选项卡中 它会记录你项目的所有依赖树

然后查找哪些库正在使用重复依赖项

例如
implementation 'com.github.bumptech.glide:glide:4.6.1' 正在使用重复的依赖项 所以改变

implementation 'com.github.bumptech.glide:glide:4.6.1'

implementation('com.github.bumptech.glide:glide:4.6.1') {
    exclude group: 'com.android.support'
}

就是这样..

这可能是因为依赖项的版本不匹配。一个类似的问题, 我检查了它的依赖树:

android.arch.lifecycle:extensions:1.0.0-beta1

android.arch.lifecycle:livedata-core:1.1.0

看到不匹配 1.0.0 & 1.1.0

在你的情况下尝试更新:

implementation 'com.firebaseui:firebase-ui-storage:3.2.1'
implementation 'com.firebaseui:firebase-ui-database:3.0.0'

至:

implementation 'com.firebaseui:firebase-ui-storage:3.2.2'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'

这应该有望解决问题。

what is the "LiveData.class" actually I dont understand

请阅读this.

我遇到了同样的问题。我检查了依赖关系树,发现一些库包含 android.arch.lifecyle 依赖关系。在我的例子中,一个依赖项包括 android.arch.lifecycle 的 1.1.0,而其他一些依赖项包括版本 1.1.1。我通过在 build.gradle 应用程序模块中添加以下行来解决它。

compile ('android.arch.lifecycle:extensions:1.1.1')

现在不再包含版本 1.1.0,因为当库请求它时,它会自动升级到版本 1.1.1。