2017-06-14 57 views
5

爲什麼會出現這個錯誤,當我同步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''來提高 –

回答

7

最後問題解決了。似乎它的一個錯誤谷歌解決了這個問題的更新版本。

使用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' –

0

有時候,這個問題是因爲包括不同版本的播放服務(或其他庫)的。看看應用程序依賴使用如下:

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'中的問題,在更高版本中已修復 –

相關問題