问题描述
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并显示该消息.
请任何人帮我
推荐答案
您已经集成了多个依赖,它使用Apache Commons. 只需在Gradle中使用以下代码排除它们.
compile('YOUR_DEPENDENCY') { exclude module: 'commons-io' }
其他推荐答案
找到了此问题的解决方案.您需要从App Build.gradle中排除Common-IO.
android { configurations{ all*.exclude module: 'commons-io' } }
其他推荐答案
techierj 答案是正确的,但它也将排除Commons-IO:2.4,在我的情况下我需要那个.所以你可以被特定组排除:
compile('YOUR_DEPENDENCY') { exclude group: 'org.apache.commons', module: 'commons-io' }
这将只排除来自org.apache.commons的1.3.2版本,并且将Mantain Commons.Io:Commons.io:2.4
问题描述
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
推荐答案
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' }
其他推荐答案
Found the solution for this issue . You need to exclude common-io from your app build.gradle .
android { configurations{ all*.exclude module: 'commons-io' } }
其他推荐答案
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