Error:Execution failed for task ':java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class

試著忘記壹切 提交于 2020-01-07 03:12:05

问题


Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class

It occurs this error.

The app builds success but when I get build apk, android studio show this message

This is my gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25'
    defaultConfig {
        applicationId "com.example.thewell_dev.fourscompany"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.mobsandgeeks:android-saripaar:2.0.3'
    compile 'com.koushikdutta.ion:ion:2.1.9'
    compile 'gun0912.ted:tedpermission:1.0.2'
    compile 'com.android.support:design:22.+'
    compile 'com.estimote:sdk:0.13.0'
    compile 'jp.wasabeef:glide-transformations:2.0.0'
    compile 'com.afollestad:easyvideoplayer:0.3.0'
    compile 'com.github.jrvansuita:PickImage:v2.0.0'
    compile 'com.amazonaws:aws-android-sdk-s3:2.+'
    compile 'com.mindorks:placeholderview:0.6.0'
    compile 'com.tsengvn:Typekit:1.0.0'
    compile 'com.github.esafirm:RxDownloader:1.0.1'
    compile 'com.mlsdev.rximagepicker:library:1.1.2'
    compile 'io.reactivex:rxjava:1.0.14'
    compile 'com.kbeanie:image-chooser-library:1.5.2@aar'
    compile 'com.kbeanie:image-chooser-library:1.5.8'
    compile 'io.github.jeancsanchez.photoviewslider:photoviewslider:1.2.0'
    compile 'com.nononsenseapps:filepicker:3.1.0'
    compile 'com.gjiazhe:scrollparallaximageview:1.0'
    compile 'com.droidninja:filepicker:1.0.8'
    compile 'com.android.support:multidex:1.0.0'

}

I think external libraries have Commons-io-1.3.2.jar Commons-io-2.4.jar and both have CopyUtils.class

Anyway, It can't build apk and show that message.

Please anyone help me please


回答1:


There is more than one dependency you have integrated which uses Apache Commons. just exclude them using following code in gradle.

compile('YOUR_DEPENDENCY') {
    exclude module: 'commons-io'
}



回答2:


Found the solution for this issue . You need to exclude common-io from your app build.gradle .

android {
    configurations{
        all*.exclude module: 'commons-io'
    }
}



回答3:


Techierj answer is correct, but it will also exclude commons-io:2.4, and in my case I needed that. So you can exclude by specific group:

compile('YOUR_DEPENDENCY') {
    exclude group: 'org.apache.commons', module: 'commons-io'
}

This will only exclude version 1.3.2 from org.apache.commons, and will mantain commons.io:commons.io:2.4



来源:https://stackoverflow.com/questions/43017925/errorexecution-failed-for-task-java-util-zip-zipexception-duplicate-entry-o

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!