【问题标题】:java.util.zip.ZipException: duplicate entry: android/arch/lifecycle/LiveData$1.classjava.util.zip.ZipException:重复条目:android/arch/lifecycle/LiveData$1.class
【发布时间】:2018-03-01 14:14:13
【问题描述】:

我可以在设备上以调试模式运行我的应用程序,没有问题,但是如果我想生成签名的 apk,它会给出这个错误

错误:任务 ':app:transformDexWithDexForRelease' 执行失败。

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:com.android.dex.DexException: 多个dex文件定义Landroid/arch/lifecycle/LiveData$1;

什么是“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'

【问题讨论】:

    标签: java android android-gradle-plugin apk


    【解决方案1】:

    这可能是由于依赖的版本不匹配而发生的。类似的问题here, 我检查了它的依赖树:

    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'
    

    这应该有望解决问题。

    什么是“LiveData.class”其实我不明白

    请阅读this.

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

        【解决方案3】:

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

        首先在您的应用级 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 studio 中输入“ALT+F12”,然后粘贴 ./gradlew -q dependencies app:dependencies --configuration 在该终端中编译此命令
        • 它给出了这个错误消息 Microsoft Windows [版本 10.0.16299.248] (c) 2017 Microsoft Corporation。 C:\adt\Kpss>./gradlew -q dependencies app:dependencies --configuration compile '.'未被识别为内部或外部命令、可运行程序或批处理文件。
        猜你喜欢
        • 1970-01-01
        • 2015-09-05
        • 1970-01-01
        • 2016-02-09
        • 2016-02-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多