Gradle构建失败:java.util.zip.ZipException:重复条目:org / apache / commons / io / CopyUtils.class [英] Gradle build failed: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
问题描述
当试图在我的nexus 7上运行应用程序时,gradle构建每次都会失败并给出相同的错误: > com.android.build.api.transform.TransformException:
java.util.zip.ZipException:重复条目:
org / apache / commons / io / CopyUtils.class
$ b这个错误似乎表明
CopyUtils.class
来自commons-io
将在构建过程中包含两次。
完整日志:
信息:Gradle任务[:android:assembleDebug]
:android:preBuild UP-TO-DATE
:android: preDebugBuild UP-TO-DATE
:安卓:checkDebugManifest
:安卓preReleaseBuild UP-TO-DATE
:安卓prepareComAndroidSupportMultidex101Library UP-TO -DATE
:android:prepareDebugDependencies
:android:compileDebugAidl UP-TO-DATE
$ b:android:compileDebugRenderscript UP-TO-DATE
:android:generateDebugBuildConfig UP-TO-DATE
$ b:android:mergeDebugShaders UP-TO-DATE
$ b:android:compileDebugShaders最新版
:android:generateDeb ugAssets升级日期
:android:mergeDebugAssets升级日期
:android:generateDebugResValues升级日期
:android:generateDebugResources UP-TO-DATE
$ b $:android:mergeDebugResources UP-TO-DATE
$ b $:android:processDebugManifest最新版
:android:processDebugResources UP-TO-DATE
:android:generateDebugSources UP-TO-DATE
:android:incrementalDebugJavaCompilationSafeguard最新版
:android:compileDebugJavaWithJavac UP-TO-DATE
:android:compileDebugNdk UP-TO-DATE
$ b:android:compileDebugSources最新版
:安卓:prePackageMarkerForDebug
:安卓:transformClassesWithJarMergingForDebug失败
错误:执行失败的任务
':机器人:transformClassesWithJarMergingForDebug'。
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException:重复条目:
org / apache / commons / io / CopyUtils.class
信息:建立失败
信息:总时间:11.208秒
信息:1个错误
信息:0个警告
信息:查看控制台中的完整输出
另外我的build.gradle:
apply插件:'android'
android {
compileSdkVersion 19
buildToolsVersion19.1.0
$ b defaultConfig {
applicationIdorg.wildstang.wildrank.android
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName 1.0
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize4g
}
compileOptions {
sourceCompatibility JavaVersion。 VERSION_1_7
targetCompatibility J avaVersion.VERSION_1_7
}
buildTypes {
发布{
minifyEnabled假
proguardFiles getDefaultProguardFile( 'proguard的-android.txt'),proguard的规则.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
编译'com.android.support:support-v4:19.+'
编译'com.android.support:support-v13:19.+'
编译'de.congrace:exp4j :0.3。+'
compile'org.apache.commons:commons-io:1.3。+'
编译fileTree(dir:'libs',include:['* .jar'])
我现在好像得到了
错误:(43,0)未找到Gradle DSL方法:'com.android.support:support-v4:24.1.1()'
可能的原因:
打开Gradle包装文件
申请Gradle插件
我的Gradle包装器
Wed Jul 06 21:02 :27 PDT 2016
distributionBase = GRADLE_USER_HOME
distributionPath =包装纸/ dists中
zipStoreBase = GRADLE_USER_HOME
zipStorePath =包装/ dists
distributionUrl = https://services.gradle.org/distributions/gradle- 2.10-all.zip
我的新gradle文件
应用插件:'com.android.application'/ /重要:'com.android.application'不是 } 依存关系{ } level 冲突的原因是 你可以看到依赖来自何处 When trying to run the app on my nexus 7, the gradle build fails every time and gives the same error: The error seems to indicate that The full log: Also my build.gradle: I seem to now get Error:(43, 0) Gradle DSL method not found: 'com.android.support:support-v4:24.1.1()'
Possible causes:
$ b
compileSdkVersion 24 //编译sdk应该总是最新
buildToolsVersion24.0。 1//不知道这是否重要
$ $ p $ $ $ c $ defaultConfig {
applicationIdorg.wildstang.wildrank.android
minSdkVersion 14
targetSdkVersion 19 //看起来这是一个新的应用程序,为什么使用19而不是24?
versionCode 1
versionName1.0
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize4g
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
编译fileTree(包括:['* .jar'],dir:'libs')//重要
//忽略这些,我不认为它们对你很重要,但我需要它们让我的测试项目编译
//这些版本号对我有用:
compile'com.android.support: support-v4:24.1.1'{exclude group:'org.apache.commons',module:'commons-io'}
compile'com.android.support:support-v13:24.1.1'{exclude module:'commons-io'}
compile'de.congrace:exp4j:0.3.11'{exclude module:'commons -io'}
compile'org.apache.commons:commons-io:1.3.2'{exclude module:'commons-io'}
configurations.all {
resolutionStrategy.dependencySubstitution {
替换模块('org.apache.commons :commons-io:1.3.2')with module('commons-io:commons-io:1.3.2')
}
}
org.apache.commons:commons-io:1.3.2
被推送错误地 https://stackoverflow.com/a/37421794/624706
gradle:main :dependencyInsight --configuration compile --dependency commons-io
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
org/apache/commons/io/CopyUtils.class
CopyUtils.class
from commons-io
is being included twice in the build process.Information:Gradle tasks [:android:assembleDebug]
:android:preBuild UP-TO-DATE
:android:preDebugBuild UP-TO-DATE
:android:checkDebugManifest
:android:preReleaseBuild UP-TO-DATE
:android:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:android:prepareDebugDependencies
:android:compileDebugAidl UP-TO-DATE
:android:compileDebugRenderscript UP-TO-DATE
:android:generateDebugBuildConfig UP-TO-DATE
:android:mergeDebugShaders UP-TO-DATE
:android:compileDebugShaders UP-TO-DATE
:android:generateDebugAssets UP-TO-DATE
:android:mergeDebugAssets UP-TO-DATE
:android:generateDebugResValues UP-TO-DATE
:android:generateDebugResources UP-TO-DATE
:android:mergeDebugResources UP-TO-DATE
:android:processDebugManifest UP-TO-DATE
:android:processDebugResources UP-TO-DATE
:android:generateDebugSources UP-TO-DATE
:android:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:android:compileDebugJavaWithJavac UP-TO-DATE
:android:compileDebugNdk UP-TO-DATE
:android:compileDebugSources UP-TO-DATE
:android:prePackageMarkerForDebug
:android:transformClassesWithJarMergingForDebug FAILED
Error:Execution failed for task
':android:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
org/apache/commons/io/CopyUtils.class
Information:BUILD FAILED
Information:Total time: 11.208 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "org.wildstang.wildrank.android"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:support-v13:19.+'
compile 'de.congrace:exp4j:0.3.+'
compile 'org.apache.commons:commons-io:1.3.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
My Gradle wrapper
Wed Jul 06 21:02:27 PDT 2016
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
My new gradle file
apply plugin: 'com.android.application' //IMPORTANT: 'com.android.application' not
android { compileSdkVersion 24 // compile sdk should always be latest buildToolsVersion "24.0.1" // Don't know if this matters
defaultConfig {
applicationId "org.wildstang.wildrank.android"
minSdkVersion 14
targetSdkVersion 19 //Looks like this is a new app, why are you using 19 and not 24?
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') //IMPORTANT
//Ignore these, I don't think they are important for you, but I needed them to get my test project to compile
// These version numbers worked for me:
compile 'com.android.support:support-v4:24.1.1'{exclude group: 'org.apache.commons', module: 'commons-io' }
compile 'com.android.support:support-v13:24.1.1'{ exclude module: 'commons-io' }
compile 'de.congrace:exp4j:0.3.11'{ exclude module: 'commons-io' }
compile 'org.apache.commons:commons-io:1.3.2'{ exclude module: 'commons-io' }
}
There is an option to fix it on gradle dependency resolution level
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module('org.apache.commons:commons-io:1.3.2') with module('commons-io:commons-io:1.3.2')
}
}
Reason of the conflict is that org.apache.commons:commons-io:1.3.2
was pushed by mistake https://stackoverflow.com/a/37421794/624706
You can see where dependency is coming from with
gradle :main:dependencyInsight --configuration compile --dependency commons-io
这篇关于Gradle构建失败:java.util.zip.ZipException:重复条目:org / apache / commons / io / CopyUtils.class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!