2014-11-25 89 views
4

當使用minifyEnabled時,我得到「重複的zip條目錯誤」。 Android Studio中的重複壓縮條目[commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class])

版本:1.0 RC 1
OS版本:MAC OS 10.9.5
的Java JRE/JDK版本: 「1.7.0_71」
搖籃:0.14.0

下面是一些我的build.gradle設置。

compileSdkVersion 21 
buildToolsVersion "21.1.1" 

packagingOptions { 
    exclude 'META-INF/DEPENDENCIES.txt' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/notice.txt' 
    exclude 'META-INF/MANIFEST.MF' 
    exclude 'META-INF/license.txt' 
    exclude 'META-INF/dependencies.txt' 
} 

buildTypes { 
    release { 
     minifyEnabled true 
     //proguardFile file('proguard-project.txt') 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' 
    } 
    debug { 
     minifyEnabled true 
     //proguardFile file('proguard-project.txt') 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' 
     debuggable true 
     applicationIdSuffix = '.alpha' 
     versionNameSuffix = 'a' 
    } 
} 
dependencies { 
compile 'com.android.support:support-v4:21.0.0' 
compile 'com.android.support:appcompat-v7:21.0.2' 
compile project(':modules:Aviary-SDK') 
compile project(':modules:facebook') 
compile ('com.crashlytics.android:crashlytics:1.+'){ 
    exclude group: 'commons-io', module: 'commons-io' //added this because crashlytics seems to be using commons-io 
} 
compile 'com.google.android.gms:play-services:6.1.11' 
compile 'org.apache.httpcomponents:httpcore:4.3.2' 
compile 'org.apache.httpcomponents:httpmime:4.3.5' 
} 

我得到這個錯誤消息時我assembleDebug:

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:proguardDebug'. 
> java.io.IOException: Can't write [/Users/tomoaki/Workspace/temp/someproject/app/build/intermediates/classes-proguard/debug/classes.jar] (Can't read [/Users/tomoaki/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class])) 

我讀this question但答案並沒有爲我工作。任何幫助表示讚賞。

+1

你可以運行「gradlew::依賴關係」。將「」替換爲您的應用模塊的名稱。它看起來像「commons-io」出現在除「crashlytics」之外的其他一些庫中,您可能需要排除它。請發佈結果。謝謝。 – AndroidGuy 2014-11-25 03:57:17

+0

@AndroidGuy感謝您的幫助!我運行了這個命令,並將它放在[gist](https://gist.github.com/tomoima525/97eaf11e59698b57afe6)中。 看起來像鳥舍有「commons-io」。我想: 編譯項目( ':模塊:百鳥-SDK'){ 排除組: '公地IO',模塊: '公地IO' } ,但沒有奏效。我找到了一個錯誤的Gradle DSL方法沒有找到:排除() – tomoima525 2014-11-25 07:18:11

+0

鬆散相關,但同樣的技巧工作:我遇到了同樣的問題,其中commons-io似乎取決於「commons-io:commons-io」。 ..這是一個棘手的事情要注意,因爲它似乎無害,因爲它們具有相同的名稱,但它的傳遞依賴可能導致欺騙錯誤 – jayunit100 2015-03-11 03:27:08

回答

0

既然你發現它是觀鳥的好,你可以嘗試:

編譯(項目( ':模塊:百鳥-SDK')) {排除組: '公地IO',模塊:' commons-io'}

這樣你就不會得到DSL錯誤。

+0

感謝您的評論。是的,它的工作!我沒有把()放到項目中(':modules:Aviary-SDK'),這就是爲什麼它沒有工作。非常感謝! – tomoima525 2014-11-25 10:05:00