2016-11-08 58 views
0

下面是我添加後發生的錯誤Firebase,gradle中的Google服務以及應用模塊中的google-services.json。com.android.build.api.transform.TransformException:java.util.zip.ZipException:重複條目:com/google/android/gms/common/api/zza.class

我在我的應用程序中有13個模塊。我在所有模塊中有7個構建變體。我嘗試將google-services.json放在應用程序模塊中,並將其放置在應用程序模塊內部的變體文件夾中。我得到同樣的錯誤。我在一個構建變體中具有通知功能。

我從應用程序中刪除了gradle和google-services.json中的firebase相關代碼,它工作得很完美。

由於安全原因,我無法共享整個文件。

主要應用模塊gradle這個:

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1' 
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1' 
    testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1' 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
    compile 'com.android.support:support-v4:23.4.0' 
    compile 'com.jakewharton:butterknife:8.2.1' 
    apt 'com.jakewharton:butterknife-compiler:8.2.1' 
    compile 'com.github.hotchemi:permissionsdispatcher:2.0.7' 
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.0.7' 
    compile 'org.greenrobot:eventbus:3.0.0' 
    compile 'com.android.support:multidex:1.0.1' 

} 

在應用gradle這個:

dependencies { 
    classpath 'com.android.tools.build:gradle:2.1.3' 

    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 

    classpath 'com.google.gms:google-services:3.0.0' 
} 

:應用:transformClassesWithJarMergingForSmePreDebug失敗 失敗:建立失敗,一個例外。

* What went wrong: 
Execution failed for task ':app:transformClassesWithJarMergingForSmePreDebug'.> 

com.android.build.api.transform.TransformException: java.util.zip.ZipException:重複的條目: COM /谷歌/安卓/ GMS /普通/ API/zza.class

我在這個問題上在StackOverflow中獲得了很多鏈接。沒有解決我的問題。任何建議感激。

編輯推送通知的Gradle模塊:

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    //compile 'com.google.android.gms:play-services-gcm:9.0.0' 

    compile 'com.google.firebase:firebase-messaging:9.8.0' 
    //compile ('com.google.firebase:firebase-messaging:9.8.0') { 
     //exclude group: 'com.google.android.gms' 
    //} 
} 
apply plugin: 'com.google.gms.google-services' 

回答

2

此問題可能是因爲你有重複的依賴關係。一個有最新版本,另一個有舊版本。

你可以做的是

  1. 檢查您的應用程序依賴條件。

    ./gradlew clean :app:dependencies 
    
  2. 查找也包含com.google.android.gms的第三方庫。

  3. 排除這一組庫

    compile ('library') { 
        exclude group: 'com.google.android.gms' 
    } 
    

這也許能速戰速決。但它不好!

最好的解決方案應該是更新你的第三方庫,他們的最新版本可能已經更新他們的谷歌服務庫。

+0

我已經檢查過這個解決方案,它沒有工作。我再次檢查並更新你。 –

+0

排除組方法也不適用於我。但是你試過最後一個嗎?更新派對或強制衝突庫的版本?這一個解決了我的問題。 – Shumin

+0

我編輯我的問題,請參閱。我嘗試過你,而不是爲我工作。這是我在項目中使用的gradle依賴項。我嘗試過,並且無法在gradle中找到版本衝突。你能幫忙找到嗎? –

相關問題