如何解决 java.util.zip.ZipException? [英] How to resolve java.util.zip.ZipException?

查看:26
本文介绍了如何解决 java.util.zip.ZipException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论何时我尝试调试和部署我的 android 应用程序(在 Android Studio 0.9 中),我都会收到以下错误:

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:

  1. 今天早上项目运行良好
  2. 添加了一些额外的类和方法
  3. 打破限制并收到此错误:无法执行 dex:方法 ID 不在 [0, 0xffff] 中:65536
  4. 决定为我的项目添加 multiDex 支持,因为不能减少依赖项

从那以后,我一直在按照此 SO 帖子将 multiDex 添加到我的项目后收到所描述的错误 使用Gradle将外部库拆分成单独的dex文件,解决Android Dalvik 64k方法限制.

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.

这是我的 build.gradle 文件:

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/<filename>".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'
}

我还有另一个项目依赖项来使用 viewPagerIndicator 库以及我的/libs 文件夹中的一些 jar:

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 !

推荐答案

这是一个错误,需要修复.请参阅 https://code.google.com/p/android/issues/detail?id=81804

我也有这个问题,我没有答案.但这是我可以添加的:

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

BuildConfig 类是在构建过程中生成的魔法类.出于某种原因,在 mutildex-1.0.0multidex 中存在具有相同完全限定名称 (android.support.multidex.BuildConfig) 的版本-instrumentation-1.0.0 aars.

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.

这篇关于如何解决 java.util.zip.ZipException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆