【问题标题】:Duplicate zip entry [commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class])重复的 zip 条目 [commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class])
【发布时间】:2014-11-25 02:58:10
【问题描述】:

使用 minifyEnabled 时出现“重复的 zip 条目错误”。

Android Studio 版本:1.0 rc 1
操作系统版本:Mac OS 10.9.5
Java JRE/JDK 版本:“1.7.0_71”
摇篮:0.14.0

这是我的一些 build.gradle 设置。

compileSdkVersion 21
buildToolsVersion "21.1.1"

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/MANIFEST.MF'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
}

buildTypes {
    release {
        minifyEnabled true
        //proguardFile file('proguard-project.txt')
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
    }
    debug {
        minifyEnabled true
        //proguardFile file('proguard-project.txt')
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        debuggable true 
        applicationIdSuffix = '.alpha' 
        versionNameSuffix = 'a'
    }
}
dependencies {
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.2'
compile project(':modules:Aviary-SDK')
compile project(':modules:facebook')
compile ('com.crashlytics.android:crashlytics:1.+'){
    exclude group: 'commons-io', module: 'commons-io'  //added this because crashlytics seems to be using commons-io
}
compile 'com.google.android.gms:play-services:6.1.11'
compile 'org.apache.httpcomponents:httpcore:4.3.2'
compile 'org.apache.httpcomponents:httpmime:4.3.5'
}

我在 assembleDebug 时收到此错误消息:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:proguardDebug'.
> java.io.IOException: Can't write [/Users/tomoaki/Workspace/temp/someproject/app/build/intermediates/classes-proguard/debug/classes.jar] (Can't read [/Users/tomoaki/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class]))

我阅读了this question,但答案对我不起作用。任何帮助表示赞赏。

【问题讨论】:

  • 你能运行“gradlew::dependencies”吗?将“”替换为您的应用模块的名称。看起来“commons-io”出现在“crashlytics”之外的其他几个库中,您可能需要将其排除。请张贴结果。谢谢。
  • @AndroidGuy 感谢您的帮助!我运行了命令并将其放入gist。看起来 Aviary 有“commons-io”。我试过: compile project(':modules:Aviary-SDK'){ exclude group: 'commons-io', module: 'commons-io' } 但它没有用。我收到一个错误 Gradle DSL method not found: exclude()
  • 松散相关,但同样的伎俩有效:我遇到了同样的问题,其中 oac commons-io 似乎依赖于名为 'commons-io:commons-io' 的东西......这是一个棘手的问题需要注意的事情,因为考虑到它们具有相同的名称,这似乎是无害的,但它是一种传递依赖,可能会导致重复错误

标签: android android-studio android-gradle-plugin


【解决方案1】:

既然你发现它也在 Aviary 中,你可以试试:

编译(project(':modules:Aviary-SDK')) { 排除组:'commons-io',模块:'commons-io' }

这样您就不会收到 DSL 错误。

【讨论】:

  • 感谢您的评论。是的,它成功了!我没有把 () 放到 project(':modules:Aviary-SDK') 中,这就是它不起作用的原因。非常感谢!
猜你喜欢
  • 2016-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-25
  • 1970-01-01
  • 2019-05-20
  • 2012-04-07
相关资源
最近更新 更多