【问题标题】:Error:Execution failed for task ':java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class错误:任务执行失败:java.util.zip.ZipException:重复条目:org/apache/commons/io/CopyUtils.class
【发布时间】:2017-03-25 15:01:03
【问题描述】:
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'

}

我认为外部库有 Commons-io-1.3.2.jar Commons-io-2.4.jar 并且都有 CopyUtils.class

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

请大家帮帮我

【问题讨论】:

标签: android build apk


【解决方案1】:

您集成的依赖项不止一个,它使用 Apache Commons。 只需在 gradle 中使用以下代码排除它们即可。

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

【讨论】:

  • 两天前我也遇到了同样的问题。用你所有的依赖试试这个,它肯定会起作用。
  • 5 你解决了吗?试试这样?编译'com.android.support:appcompat-v7:23.2.0'{排除模块:'commons-io'}编译'com.android.support.constraint:constraint-layout:1.0.2'{排除模块:'commons -io' } testCompile 'junit:junit:4.12'{ exclude module: 'commons-io' } compile 'com.mobsandgeeks:android-saripaar:2.0.3'{ exclude module: 'commons-io' } ... 像这个?
  • yes exclude module: 'commons-io' 帮我解决了这个问题。
  • 只要找到你的 gradle 的 Dependecy 树,然后找到 common-io 的使用位置,然后像这样compile ('com.mobsandgeeks:android-saripaar:2.0.3'){ exclude module: 'commons-io' }
  • 找到项目依赖给定的链接会帮助你..mkyong.com/gradle/gradle-display-project-dependency
【解决方案2】:

找到了这个问题的解决方案。您需要从您的应用 build.gradle 中排除 common-io。

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

【讨论】:

    【解决方案3】:

    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

    【讨论】:

      猜你喜欢
      • 2016-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多