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

时间:2017-06-14 05:58:48

标签: android android-gradle

当我同步Gradle时,为什么会出现此错误,但是当我运行项目时,我收到此错误。

  

错误:任务':app:transformClassesWithJarMergingForRelease'的执行失败。 > com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目: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:1.1.5@aar'
    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,但它给了我上述问题。如何解决这个问题?任何帮助都会受到感谢。

2 个答案:

答案 0 :(得分:7)

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

使用播放服务版本11.0.1

在项目级别使用中

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

答案 1 :(得分:0)

有时,出现此问题是因为包含了不同版本的播放服务(或其他一些库)。使用以下内容查看应用程序依赖项:

gradle app:dependencies

或者如果您使用的是Gradle包装器

./ gradlew app:dependencies

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

您可以这样做:

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

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