java.util.zip.ZipException: duplicate entry during packageAllDebugClassesForMultiDex

后端 未结 21 1297
孤街浪徒
孤街浪徒 2020-11-22 07:37

I am not sure what this error means.

Execution failed for task \':excelSior:packageAllDebugClassesForMultiDex\'.
> java.util.zip.ZipException: duplicate          


        
相关标签:
21条回答
  • 2020-11-22 08:11

    Try this:

    android {
    configurations {
            all*.exclude  module: 'PhotoView'  //去除重复依赖库
        }
    }
    
    0 讨论(0)
  • 2020-11-22 08:12

    For me something similar happened when I had accidently added

    apply plugin: 'kotlin-android'
    

    to my android library module. Removing the line fixes the issue.

    0 讨论(0)
  • 2020-11-22 08:14

    just erase android/support/v4/util/TimeUtils.class

    0 讨论(0)
  • 2020-11-22 08:15

    find out the lib depends on the support v4, and exclude it.

    code in build.gradle is like this:

    androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
        // http://stackoverflow.com/a/30931887/5210
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    

    In my situation, the lib 'espresso' has a jar called support-v4 and in my project 'app' have the same support-v4, exclude the support-v4 when import espresso.

    PS: it seems compile project can not work with the exclude

    0 讨论(0)
  • 2020-11-22 08:18

    In my case the mentioned "duplicate entry" error arised after settingmultiDexEnable=true in the build.gradle.

    In order to fully resolve the error first of all have a look at Configure Apps with Over 64K Methods (espescially "Configuring Your App for Multidex with Gradle").

    Furthermore search for occurences of the class that causes the "duplicate entry" error using ctrl+n in Android Studio. Determine the module and dependency that contains the duplicate and exclude it from build, e.g.:

    compile ('org.roboguice:roboguice:2.0') {
        exclude module: 'support-v4'
    }
    

    I had to try multiple module labels till it worked. Excluding "support-v4" solves issues related to "java.util.zip.ZipException: duplicate entry: android/support/v4/*"

    0 讨论(0)
  • 2020-11-22 08:20

    I have faced this issue as i have manually copied the jar in libs as well as mentioned the dependency in gradle file. You also check in your project structure, whether the same jar file is copied in any other folder like libs or in project folder.

    0 讨论(0)
提交回复
热议问题