关于错误java.util.zip.ZipException: duplicate entry during packageAllDebugClassesForMultiDex

在导入几个外部jar包至AS中lib文件夹,并add as library后,build.gradle文件中生成:

dependencies {
    // lib编译jar包
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile('io.socket:socket.io-client:0.7.0') {
        exclude group: 'org.json', module: 'json'
    }
    compile 'com.google.android.gms:play-services:8.4.0'
    compile project(':library')
    compile files('src/main/libs/universal-image-loader-1.9.4.jar')
    compile files('src/main/libs/json-lib-2.4-jdk15.jar')
    compile files('src/main/libs/commons-collections-3.2.2.jar')
    compile files('src/main/libs/ezmorph-1.0.6.jar')
    compile files('src/main/libs/commons-beanutils-1.7.0.jar')
    compile files('src/main/libs/commons-lang-2.5.jar')
    compile files('src/main/libs/commons-logging.jar')
}

编译报错如标题。

解决办法:
http://stackoverflow.com/questions/26966843/java-util-zip-zipexception-duplicate-entry-during-packagealldebugclassesformult

My understanding is that there are duplicate references to the same API (Likely different version numbers). It should be reasonably easy to debug when building from the command line.

Try ./gradlew yourBuildVariantName –debug from the command line.

The offending item will be the first failure. An example might look like:

14:32:29.171 [INFO] [org.gradle.api.Task] INPUT: /Users/mydir/Documents/androidApp/BaseApp/build/intermediates/exploded-aar/theOffendingAAR/libs/google-play-services.jar

14:32:29.171 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ‘:BaseApp:packageAllyourBuildVariantNameClassesForMultiDex’

14:32:29.172 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :BaseApp:packageAllyourBuildVariantNameClassesForMultiDex FAILED’
In the case above, the aar file that I’d included in my libs directory (theOffendingAAR) included the Google Play Services jar (yes the whole thing. yes I know.) file whilst my BaseApp build file utilised location services:

compile 'com.google.android.gms:play-services-location:6.5.87'

You can safely remove the offending item from your build file(s), clean and rebuild (repeat if necessary).

简单说就是移除compile ‘com.google.android.gms:play-services-location:xxx’来解决。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值