重复的zip条目改造 - 1.3.0

时间:2015-10-05 10:46:18

标签: android android-gradle build.gradle retrofit

当我尝试使用Proguard激活创建已签名的Apk时出现错误,相对于带有改造的重复zip条目:

Note: there were 110 duplicate class definitions.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning:can't write resource [.readme] (Duplicate zip entry [classes.jar:.readme])
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-lang3-3.2.1.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [commons-lang3-3.2.1.jar:META-INF/NOTICE.txt])
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-io-1.3.2.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [commons-io-1.3.2.jar:META-INF/NOTICE.txt])
Warning:can't write resource [.readme] (Duplicate zip entry [classes.jar:.readme])
:app:proguardAppRelease FAILED
Error:Execution failed for task ':app:proguardAppRelease'.
> java.io.IOException: Can't write [/Users/me/Projects/myProject/app/build/intermediates/classes-proguard/app/release/classes.jar] (Can't read [/Users/me/Projects/myProject/app/build/intermediates/exploded-aar/myProject/mySubProject/unspecified/jars/libs/retrofit-1.3.0.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [b/a/a.class == retrofit-1.3.0.jar:retrofit/android/AndroidApacheClient.class]))

这是我在build.gradle中的依赖:

dependencies {
    compile 'joda-time:joda-time:2.7'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:support-v4:19.1.0'

    compile 'com.google.code.gson:gson:2.2.4'
    compile('com.octo.android.robospice:robospice-retrofit:1.4.11') {
        exclude group: 'commons-io', module: 'commons-io'
    }
    compile('com.squareup.okhttp:okhttp:1.5.4')
    compile 'com.google.android.gms:play-services:5.0.89'
    compile 'com.splunk.mint:mint:4.0.5'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/PushLinkAndroid-5.3.0.jar')
    compile project(':mobihelp_sdk_android_v1.5.4')
}

我还添加了这个packaginOptions:

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

我想知道是否有可能通过从我的编译中排除retrofit-1.3.0来解决这个问题(' com.octo.android.robospice:robospice-retrofit:1.4.11& #39;)或者是否还有其他更好的解决方案。

2 个答案:

答案 0 :(得分:0)

尝试将其添加到build.gradle文件中。

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

修改

根据与您的问题相同的this issue,您可以这样做。

compile ('com.octo.android.robospice:robospice-retrofit:1.4.13') {
    exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'commons-io:commons-io:1.3.2'

希望它对你有用。

答案 1 :(得分:0)

我的依赖项部分都有

compile ('com.squareup.retrofit:retrofit:1.9.0') {
        exclude group: 'org.apache.commons', module: 'commons-io'
    } and compile fileTree(dir: 'libs', include: ['*.jar']). 

这意味着我已经将库包含两次,因此错误。从依赖项中删除compile fileTree(dir: 'libs', include: ['*.jar'])时,一切都按预期工作