【问题标题】:Fail to Generate Signed APK : java.util.zip.ZipException: duplicate entry生成签名 APK 失败:java.util.zip.ZipException:重复条目
【发布时间】:2016-06-29 00:56:58
【问题描述】:

我曾尝试构建我的 android 项目。当我重建项目时,只有很少的警告没有错误。但是当我尝试生成签名的 apk 时,它显示以下错误:

错误:任务 ':app:packageAllReleaseClassesForMultiDex' 执行失败。 java.util.zip.ZipException:重复条目:org/apache/http/ConnectionClosedException.class

我知道 ConnectionClosedException.class 在我的依赖项中是重复的,但我找不到它。任何机构都知道如何处理这个问题? build.gradle 中的依赖如下:

dependencies {
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'org.apache.httpcomponents:httpcore:4.4.5'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.android.support:support-v13:24.0.0'
compile files('libs/httpmime-4.2.jar')
compile files('libs/android-support-v4.jar')} 

非常感谢~

2016.06.29 在我调整依赖关系之后:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'org.apache.httpcomponents:httpcore:4.4.5'
compile 'org.apache.httpcomponents:httpmime:4.5.2'
compile 'com.android.support:support-v4:23.0.0'}

错误变成:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. >com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/entity/mime/HttpMultipart$1.class

有人知道如何检查哪个依赖库与其他依赖库冲突吗?

【问题讨论】:

  • 如果我不得不猜测,它在 OSGI 或 httpmime 包中,而且,您不需要 v4 jar 文件... appcompat-v7 已经包含该文件
  • 此外,我非常怀疑您是否需要整个播放服务依赖项。在此处阅读有关选择性编译您实际需要的内容的信息。这将减少构建应用程序所需的时间和最终应用程序的大小。 developers.google.com/android/guides/setup#split

标签: android


【解决方案1】:

总是尽量使用Maven依赖来防止重复,所以替换

compile files('libs/httpmime-4.2.jar')

compile 'org.apache.httpcomponents:httpmime:4.5.2'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-09
    • 2021-11-23
    • 2018-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多