java.util.zip.zipexception_如何解决java.util.zip.ZipException?

在尝试部署使用了multiDex支持的Android应用时,出现了'java.util.zip.ZipException: duplicate entry: android/support/multidex/BuildConfig.class'错误。错误发生在添加multiDex后,尽管已遵循SO上的指南。项目依赖包括multidex库和其他多个库。解决方案可能涉及检查并解决库冲突。
摘要由CSDN通过智能技术生成

Whever I try to debug and deploy my android application (in Android Studio 0.9) I get the following error:

Execution failed for task ':app:packageAllDebugClassesForMultiDex'.

java.util.zip.ZipException: duplicate entry: android/support/multidex/BuildConfig.class

To make things clear here is a brief history of my actions:

This morning the project was working fine

Added some additional classes and methods

Broke the limit and received this error: Unable to execute dex: method ID not in [0, 0xffff]: 65536

Decided to add multiDex support to my project as reducing the dependencies was not an option

Since then I keep getting the described error just after adding multiDex to my project by following this SO post Using Gradle to split external libraries in separated dex files to solve Android Dalvik 64k methods limit.

Here is my build.gradle file:

apply plugin: 'com.android.application'

repositories {

jcenter()

}

android {

compileSdkVersion 21

buildToolsVersion '21.1.0'

defaultConfig {

applicationId "com.stackoverflow.application"

minSdkVersion 15

targetSdkVersion 21

versionCode 1

versionName "1.0"

multiDexEnabled = true

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

dexOptions {

preDexLibraries = false

}

}

afterEvaluate {

tasks.matching {

it.name.startsWith('dex')

}.each { dx ->

if (dx.additionalParameters == null) {

dx.additionalParameters = []

}

dx.additionalParameters += '--multi-dex'

dx.additionalParameters += "--main-dex-list=$projectDir/".toString() // enable the main-dex-list

}

}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile project(':viewPagerIndicatorLibrary')

compile 'com.google.android:multidex:0.1'

compile 'com.j256.ormlite:ormlite-android:4.48'

compile 'com.j256.ormlite:ormlite-core:4.48'

compile 'de.greenrobot:eventbus:2.2.1'

compile 'se.emilsjolander:stickylistheaders:2.5.1'

compile 'joda-time:joda-time:2.5'

compile 'com.makeramen:roundedimageview:1.4.0'

compile 'javax.inject:javax.inject:1'

compile 'com.squareup.picasso:picasso:2.3.4'

compile 'com.googlecode.libphonenumber:libphonenumber:6.3.1'

compile('com.google.api-client:google-api-client-gson:1.18.0-rc') {

exclude module: 'httpclient'

}

compile 'com.google.android.gms:play-services:6.1.71'

compile('com.google.api-client:google-api-client:1.17.0-rc') {

exclude(group: 'xpp3', module: 'xpp3')

exclude(group: 'org.apache.httpcomponents', module: 'httpclient')

exclude(group: 'junit', module: 'junit')

exclude(group: 'com.google.android', module: 'android')

}

compile('com.google.api-client:google-api-client-android:1.17.0-rc') {

exclude(group: 'com.google.android.google-play-services', module: 'google-play-services')

}

compile('com.google.http-client:google-http-client-android:1.17.0-rc') {

exclude(group: 'com.google.android', module: 'android')

}

compile 'com.google.guava:guava:18.0'

}

I also have another project dependencies to use the viewPagerIndicator library as well as a few jars in my /libs folder:

android-async-http-1.4.6.jar

guice-3.0-no_aop.jar

jsr305-1.3.9.jar

roboguice-2.0.jar

Any advice on how I could resolve this problem without removing any of my needed dependencies is welcomed !

解决方案

I have this problem too, and I don't have an answer. But here's what I can add:

The class BuildConfig is a magic class generated as part of the build process. For some reason, there exists a version with the same fully-qualified name (android.support.multidex.BuildConfig) in both mutildex-1.0.0 and multidex-instrumentation-1.0.0 aars.

I don't believe we have done anything wrong. I think this is a symptom of being on the cutting-edge. I raised a bug report.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值