Java.util.zip.ZipException: duplicate entry: com/g

2019-01-25 18:51发布

Why am getting this error it will not occurred when I sync the Gradle but when I'm running the project I am getting this error .

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

I don't know which dependency cause this error, My dependencies are .

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'

Edit

I figured it out play service dependencies causing this problem. when I'm using 10.2.6 instead of 11.0.0 app is working perfectly, I just change dependecies to

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'

but I want to use latest version of play-services 11.0.0 but it gives me the above problem. How to resolve this problem? Any help would be appriciated Thanks.

2条回答
三岁会撩人
2楼-- · 2019-01-25 19:14

Sometimes, this issue happens because of including different version of play-services (or some other libraries). Have a look at app dependencies using below:

gradle app:dependencies

or if you are using Gradle wrapper

./gradlew app:dependencies

There might be some other third party library that is using an older version of library. If that is the case, exclude the older library from the third party library and include the latest one.

You can do something like this:

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

This should resolve any duplicate entry, the main reason for the issue

查看更多
冷血范
3楼-- · 2019-01-25 19:15

Finally problem is solved. Seems like its a bug google resolved this issue in updated version.

Use play Service Version 11.0.1

In project level gradle use

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

查看更多
登录 后发表回答