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

后端 未结 21 1298
孤街浪徒
孤街浪徒 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:21

    For Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' com.android.build.api.transform.TransformException java.util.zip.ZipException duplicate entry com/google/gson/annotations/Expose.class

    Here is what I did:

    1) Delete the gson-2.5.jar file. 2) configurations { all*.exclude module: 'gson-2.5' }

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

    check your dependencies versions, you must have compatible versions put attention specially to com.google packages, must have same version like:

    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.google.android.gms:play-services-maps:8.3.0'
    

    Both are 8.3.0, if you have another version compilation will throw that exception.

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

    I tried all the above solutions but not working for me. I tried update libraries by goto project structure > app. And it works for me! Hope this answer helpful to someone.

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

    My understanding is that there are duplicate references to the same API (Likely different version numbers). It should be reasonably easy to debug when building from the command line.

    Try ./gradlew yourBuildVariantName --debug from the command line.

    The offending item will be the first failure. An example might look like:

    14:32:29.171 [INFO] [org.gradle.api.Task] INPUT: /Users/mydir/Documents/androidApp/BaseApp/build/intermediates/exploded-aar/theOffendingAAR/libs/google-play-services.jar
    
    14:32:29.171 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':BaseApp:packageAllyourBuildVariantNameClassesForMultiDex'
    
    14:32:29.172 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :BaseApp:packageAllyourBuildVariantNameClassesForMultiDex FAILED'
    

    In the case above, the aar file that I'd included in my libs directory (theOffendingAAR) included the Google Play Services jar (yes the whole thing. yes I know.) file whilst my BaseApp build file utilised location services:

    compile 'com.google.android.gms:play-services-location:6.5.87'
    

    You can safely remove the offending item from your build file(s), clean and rebuild (repeat if necessary).

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

    Simple Remove Your Jar file from dependencies gardle.project as v7 and run your project

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

    This is because you have added a library and given its dependency on a module more than once.

    In my case, I had added a library as a module and as a gradle dependency both.

    Removing one source of adding library (I removed gradle dependency) solved my problem.

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