错误:任务执行失败':java.util.zip.ZipException:重复条目:org / apache / commons / io / CopyUtils.class

时间:2017-03-25 15:01:03

标签: android build apk

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

发生此错误。

该应用程序构建成功,但当我获得构建apk时,android studio显示此消息

这是我的傻瓜

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'

}

我认为外部图书馆有 下议院-IO-1.3.2.jar 下议院-IO-2.4.jar 并且都有CopyUtils.class

无论如何,它无法构建apk并显示该消息。

请有人帮帮我

3 个答案:

答案 0 :(得分:0)

您使用Apache Commons集成了多个依赖项。 只需在gradle中使用以下代码排除它们。

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

答案 1 :(得分:0)

找到此问题的解决方案。您需要从app build.gradle中排除common-io。

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

答案 2 :(得分:0)

Techierj answer是正确的,但它也会排除commons-io:2.4,在我的情况下我需要它。因此,您可以按特定组排除:

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

这只会从org.apache.commons中排除1.3.2版本,并且会保留commons.io:commons.io:2.4