作者:互相体谅知足常乐 | 来源:互联网 | 2023-05-28 17:01
几个小时以来我一直在研究以下问题,但还没有找到解决问题的方法.我已经尝试了Stack Overflow中的以下修复(Android Studio更新到1.0会破坏Gradle插件v0.13.1之后的MultiDex和重复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 dependencies 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,但这也没有用.
我的项目处于停滞状态,直到我得到解决,我将不胜感激.
1> nekojsi..:
这是Robospice中一个已知且已解决的问题,由Gradle 2.1问题引起:https://github.com/stephanenicolas/robospice/issues/365.该修复程序将在下一版本中发布.
你可以解决它通过排除org.apache.commons:commons-io
来自各 Robospice的依赖,以及包括commons-io:commons-io:1.3.2
手动.像这样:
// workaround (https://github.com/stephanenicolas/robospice/issues/365)
// remove when robospice updates to 1.4.15+
compile ('com.octo.android.robospice:robospice-retrofit:1.4.14') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile ('com.octo.android.robospice:robospice-ormlite:1.4.14') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'commons-io:commons-io:1.3.2'