2017-08-03 27 views
0

遇到以下問題:** FAILURE:構建失敗,出現異常。構建簽名時APK:app:transformClassesWithJarMergingForRelease

  • 出錯: 任務':app:transformClassesWithJarMergingForRelease'的執行失敗。

    com.android.build.api.transform.TransformException:java.util.zip.ZipException:重複的條目:COM /谷歌/ GSON /註釋/ Expose.class **

這是我嘗試使用發佈已簽名的APK進行構建時的情況。然而,當我只是在Gradle中進行調試或同步時,它才起作用。

我認爲在版本控制支持或編譯依賴問題上存在問題。我只是不確定什麼是正確的方法來追蹤問題。

我試過清理然後重建。 Debug Build沒有問題,但是在簽名APK上我遇到了這個問題。

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    // Single target that includes all FirebaseUI libraries above 
    compile files('libs/YouTubeAndroidPlayerApi.jar') 
    compile files('libs/plivo-java-3.0.9-jar-with-dependencies.jar') 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.google.firebase:firebase-core:10.0.1' 
    compile 'com.google.firebase:firebase-database:10.0.1' 
    compile 'com.google.firebase:firebase-storage:10.0.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' 
    compile 'com.android.support:support-v4:23.4.0' 
    compile 'com.android.support:support-vector-drawable:23.4.0' 
    compile 'com.google.firebase:firebase-messaging:10.0.1' 
    compile 'com.firebaseui:firebase-ui:1.0.1' 
    compile 'com.android.support:recyclerview-v7:23.4.0' 
    testCompile 'junit:junit:4.12' 
    compile project(':DailymotionWebSDK') 
} 

apply plugin: 'com.google.gms.google-services' 

回答

0

這是因爲以下兩個庫都包括在其內部GSON依賴性:

compile files('libs/plivo-java-3.0.9-jar-with-dependencies.jar') 
compile project(':DailymotionWebSDK') 

對於plivo-Java SDK中,看它的pom.xml

對於DailyMotionWebSDK,看它的build.gradle

所以,你需要從其中之一中排除gson。

+0

有沒有可能的方法呢?有些人說,如果你有一個.jar文件,就不可能排除它。我嘗試了排除功能,但它不起作用。 – Aizen

+1

請嘗試使用包含plivo-java-3.0.9.jar而不是plivo-java-3.0.9-jar -with-dependencies.jar,如其README所述「如果您的項目中存在衝突瓶子問題,請使用此選項。請參閱pom.xml獲取您需要包含的依賴關係列表。https://github.com/plivo/plivo-java –