2014-11-25 86 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