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

时间:2018-03-01 14:14:14

标签: java android android-gradle apk

我可以在调试模式下在设备上运行我的应用程序并且没有问题但是如果我想生成签名的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'

3 个答案:

答案 0 :(得分:5)

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

(axis=0, axis=1, axis=2)

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'

应该有希望解决这个问题。

  

什么是" LiveData.class"实际上我不明白

请阅读this.

答案 1 :(得分:1)

我有同样的问题。我检查了依赖关系树,发现一些库包含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版。

答案 2 :(得分:0)

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

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

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

如果不解决尝试记录依赖项 运行此命令

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

在你的android studio的终端标签中 它将记录项目的所有依赖关系树

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

例如,

 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'
}

多数民众赞成......