Java.util.zip.ZipException:重复条目:com/google/common/base/FinalizableReference.class

Java.util.zip.ZipException:重复条目:com/google/common/base/FinalizableReference.class

问题描述:

为什么会出现这个错误,当我同步Gradle但是当我运行项目时,这个错误。Java.util.zip.ZipException:重复条目:com/google/common/base/FinalizableReference.class

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/common/base/FinalizableReference.class

我不知道哪个依赖的原因这个错误,我的依赖关系。

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    compile 'com.android.support:support-v4:25.3.1' 
    compile 'com.android.support:customtabs:25.3.1' 
    compile 'com.android.support:cardview-v7:25.3.1' 
    compile 'com.android.support:design:25.3.1' 
    compile 'com.android.support:percent:25.3.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.facebook.android:facebook-android-sdk:4.19.0' 
    compile 'com.google.android.gms:play-services-auth:11.0.0' 
    compile 'com.google.android.gms:play-services-location:11.0.0' 
    compile 'com.google.android.gms:play-services-maps:11.0.0' 
    compile 'com.google.android.gms:play-services-places:11.0.0' 
    compile 'com.google.maps.android:android-maps-utils:0.3.4' 
    compile 'io.nlopez.smartlocation:library:3.3.1' 
    compile 'com.appeaser.sublimenavigationviewlibrary:sublimenavigationviewlibrary:0.0.1' 
    compile 'de.hdodenhof:circleimageview:2.1.0' 
    compile 'com.android.volley:volley:1.0.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.nineoldandroids:library:2.4.0' 
    compile 'com.daimajia.slider:library:[email protected]' 
    compile 'com.afollestad:sectioned-recyclerview:0.4.1' 
    compile 'com.github.medyo:fancybuttons:1.8.3' 
    compile 'com.basgeekball:awesome-validation:2.0' 
    compile 'com.github.michaelye.easydialog:easydialog:1.4' 
    testCompile 'junit:junit:4.12' 
} 
apply plugin: 'com.google.gms.google-services' 

编辑

我想通了导致此问题的播放服务的依赖。当我使用的10.2.6代替11.0.0应用程序是可以正常使用的时候,我只是改变依赖判断

compile 'com.google.android.gms:play-services-auth:10.2.6' 
compile 'com.google.android.gms:play-services-location:10.2.6' 
compile 'com.google.android.gms:play-services-maps:10.2.6' 
compile 'com.google.android.gms:play-services-places:10.2.6' 

,但我想用最新版本的播放服务11.0.0,但它给了我上述问题。如何解决这个问题?任何帮助将appriciated谢谢。

+0

使用'编译“com.google.maps.android:android-maps- utils:0.5 +' –

+0

@IntelliJAmiya还是一样的错误 –

+0

我觉得它的一个bug。你可以通过删除这一行'apply plugin:'com.google.gms.google-services''来提高 –

最后问题解决了。似乎它的一个错误谷歌解决了这个问题的更新版本。

使用Play服务版本11.0.1 ...

在项目层面gradle这个使用

classpath 'com.google.gms:google-services:3.1.0'

+0

我有同样的问题,但如果我删除该行'应用插件:“com.google.gms.google-services''就像你建议,构建不再解析我的'谷歌services.json'文件,因此我用于Firebase消息的api密钥不会添加到R.字符串,而构建失败,因为我在几个地方使用这些。任何想法? – Breeno

+1

有没有办法你的应用程序将建立,我目前有相同的问题,因为我升级到Firebase和播放服务11.0.0,我认为这是一个错误 – Po10cio

+0

@Breeno使用播放服务版本'11.0.1' –

有时候,这个问题是因为包括不同版本的播放服务(或其他库)的。看看应用程序依赖使用如下:

gradle这个应用程序:依赖

,或者如果您使用的包装器的摇篮

./gradlew应用:依赖

可能有一些其他使用较旧版本库的第三方库。如果是这样,请从第三方库中排除较旧的库并包含最新的库。

你可以做这样的事情:

compile ('com.thirdpartylib.android:library-sdk:8.3.0') { 
     exclude group: 'com.android.support', module: 'support-v4' 
     exclude group: 'com.android.support', module: 'support-annotations' 
     exclude group: 'com.google.android.gms', module: 'play-services-gcm' 
     compile 'com.android.support:support-v4:26.0.0' 
     compile 'com.android.support:support-annotations:26.0.0' 
     compile 'com.google.android.gms:play-services-gcm:11.2.0' 
    } 

这应该解决任何重复的项目,主要的原因问题

+0

nope bro它是'11.0.0'中的问题,在更高版本中已修复 –