我已经研究以下问题几个小时了,但还没有想出解决我的问题的方法。我已经尝试了 Stack Overflow 上的以下修复(Android Studio 更新至 1.0 损坏 MultiDex and Gradle 插件 v0.13.1 后重复的 Zip 条目)但它们都不起作用。
尝试构建我的程序时出现以下错误:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
该错误似乎表明 commons-io 在构建过程中被包含两次
我正在使用 Android Studio 和 Gradle 来包含多个 Robospice 依赖项。这是我的 Gradle 构建文件的依赖项部分:
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile'com.google.api-client:google-api-client-android:1.19.0'
// You must install or update the Google Repository through the SDK manager to use this dependency.
// The Google Repository (separate from the corresponding library) can be found in the Extras category.
//compile 'com.google.android.gms:play-services:4.3.23'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.jakewharton:butterknife:${butterknifeVersion}"
compile 'com.sun.jersey:jersey-bundle:1.8'
compile 'com.google.code.gson:gson:2.3'
compile 'org.codehaus.jackson:jackson-core-asl:1.9.0'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.0'
compile ('com.octo.android.robospice:robospice:1.4.14'){
exclude module: 'commons-io'
exclude group: 'commons-io'
}
compile ('com.octo.android.robospice:robospice-spring-android:1.4.14'){
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile ('com.octo.android.robospice:robospice-google-http-client:1.4.14'){
exclude module: 'xpp3'
exclude group: 'stax'
}
compile 'org.scribe:scribe:1.3.5'
compile files("$buildDir/native-libs/native-libs.jar")
}
使用“gradlew -q dependency app:dependencies”命令查看项目的依赖树,表明com.octo.android.robospice:robospice:1.4.14依赖于commons-io库。这是项目依赖树的相关片段:
+--- com.octo.android.robospice:robospice:1.4.14
| \--- com.octo.android.robospice:robospice-cache:1.4.14
| +--- org.apache.commons:commons-lang3:3.3.2
| \--- org.apache.commons:commons-io:1.3.2
| \--- commons-io:commons-io:1.3.2
即使我从 gradle 构建文件中的所有 Robospice 相关依赖项中排除了 commons-io,该依赖项仍然列出。我还尝试将组名称从 commons-io 更改为 org.apache.commons,但这也不起作用。
在我解决这个问题之前,我的项目处于停滞状态,如果我能得到任何帮助,我将不胜感激。