2016-09-21 85 views
1
Execution failed for task `:app:transformResourcesWithMergeJavaResForDebug`. 
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE 
    File1: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar 
    File2: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar 
    File3: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar 

我使用問題的gradle同時建立重複文件在APK META-INF /許可複製

packagingOptions { 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/license.txt' 
} 

這個作品有試過,但我不想排除許可請告訴我如何避免它使用此

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.2" 

    defaultConfig { 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 

    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.android.support:support-v4:24.2.1' 
    compile 'com.android.support:design:24.2.1' 

    compile 'com.google.firebase:firebase-core:9.4.0' 
    compile 'com.google.firebase:firebase-storage:9.4.0' 
    compile 'com.google.firebase:firebase-messaging:9.4.0' 
    compile 'com.google.firebase:firebase-auth:9.4.0' 
    compile 'com.firebase:firebase-client-android:2.5.2' 

    compile 'com.squareup.retrofit2:retrofit:2.1.0' 
    compile 'com.squareup.okhttp3:okhttp:3.4.1' 
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' 
} 

這裏走出來的是我的gradle這個其中有許多依賴所以請讓我知道哪些依賴是導致該問題

+0

添加排除 '庫/傑克遜核心-ASL-1.9.13.jar' 在packagingOptions –

+0

沒有它donst工作抱歉。 – Ashish

+0

可能的重複[如何解決「在APK META-INF/\ *中複製的重複文件」](http://stackoverflow.com/questions/33923461/how-do-i-resolve-duplicate-files-copied- in-apk-meta-inf) –

回答

1

編輯:如果你想去定義的依賴關係。您需要使用以下代碼:

packagingOptions { 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/license.txt' 
    } 

否則,您需要刪除使用的依賴項,因爲它們在文件中存在衝突。

+0

它是一個同樣的事情,我不想排除爲什麼我發佈它與我目前的解決方案,我不尋找的許可證。謝謝各位 – Ashish

+0

好吧,那麼你需要改變依賴關係,因爲依賴關係在License.txt文件中發生衝突。 –

+0

但是,你能幫我解決哪些依賴造成的問題,這將是一個很大的幫助。 – Ashish

0

packagingOptions { PICKFIRST 'META-INF/LICENSE' }

我想這和它的工作的偉大,請嘗試。

+0

這與@AndroidGeek的答案完全相同。但不要混合使用Firebase SDK中各種功能的版本。這是一個問題的祕訣。 –

+0

我完全同意,因爲我發現它是gsm服務的問題。感謝您的幫助表示讚賞 – Ashish

1

您正在混合使用Firebase客戶端的各個版本,這可確保爲您帶來更多的問題。

使用一個版本的所有火力地堡的依賴,如9.4.0:

compile 'com.google.firebase:firebase-core:9.4.0' 
compile 'com.google.firebase:firebase-storage:9.4.0' 
compile 'com.google.firebase:firebase-messaging:9.4.0' 
compile 'com.google.firebase:firebase-auth:9.4.0' 
compile 'com.google.firebase:firebase-database:9.4.0' // this one changed 
相關問題