【问题标题】:Yet another zip duplicate entry又一个 zip 重复条目
【发布时间】:2016-11-22 08:18:10
【问题描述】:

我使用过 Kryo 库,它非常好。但是,当我想创建一个签名的 APK 时,由于错误,它一直无法构建:

错误:任务 ':app:transformClassesAndResourcesWithProguardForRelease' 执行失败。

java.io.IOException: Can't write [C:\AndroidProjects\App\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar] (无法读取 [C :\AndroidProjects\App\app\importLibs\minlog-1.3.0.jar(;;;;;;**.class)](重复的 zip 条目 [minlog-1.3.0.jar:com/esotericsoftware/minlog/Log $Logger.class]))

build gradle (module app)

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-ads:9.4.0'
    compile 'com.android.support:design:24.1.1'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
    compile files('importLibs/kryo-2.23.0.jar')
    compile files('importLibs/minlog-1.3.0.jar')
    compile files('importLibs/objenesis-2.1.jar')
    compile files('importLibs/reflectasm-1.10.1-shaded.jar')
}

proguard 文件

     proguard-rules.pro
    -dontwarn com.esotericsoftware.**
    -dontwarn org.objenesis.**
    -keep class com.esotericsoftware.**{*;}

我需要写什么才能让它工作?

【问题讨论】:

  • 检查importLibs 。评论compile files('importLibs/minlog-1.3.0.jar')并确保设置multiDexEnabled true
  • 注释掉minlog-1.3.0.jar只会让reflectasm-1.10.1-shaded.jar有同样的问题。将两者都注释掉会使应用程序无法运行。

标签: java android android-gradle-plugin proguard


【解决方案1】:

在某些情况下,某个库是您在项目中导入的另一个库的一部分 使用以下命令检查 lib 依赖树 对于 Android,请使用此行

gradle app:dependencies

或者如果你有一个 gradle 包装器:

./gradlew app:dependencies

或者有一个不太流行的 Android Studio 插件,称为 GradleView,它可以为您提供应用程序中使用的整个库树,以及它可能与其他库发生冲突的地方。

【讨论】:

    【解决方案2】:

    我遇到了类似的问题,我通过添加 retrofit 解决了它: 'com.squareup.retrofit:retrofit:1.9.0'

    希望对你也有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      • 2017-02-18
      • 1970-01-01
      • 1970-01-01
      • 2017-06-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多