Android编译异常: duplicate entry: META-INF/MANIFEST.MF`或Entry name 'META-INF/MANIFEST.MF' collided

Android编译异常` Cause: duplicate entry: META-INF/MANIFEST.MF`

这是转载大佬的博客:https://www.cnblogs.com/AsionTang/p/11929529.html

目录Android编译异常Cause: duplicate entry: META-INF/MANIFEST.MF或者是:Entry name 'META-INF/MANIFEST.MF' collided

解决方案2: 治标又治本(暂无)

解决方案1: 治标不治本(还原大法)

  1. 还原到classpath 'com.android.tools.build:gradle:3.4.2' 即可.

参考资料

  1.  

问题详情

  1. 旧项目 AndroidStudio3.4 编译正常

    classpath 'com.android.tools.build:gradle:3.4.2'

    gradle/wrapper/gradle-wrapper.properties
    distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

  2. 升级到 AndroidStudio3.5 编译报错

    classpath 'com.android.tools.build:gradle:3.5.2'

    gradle/wrapper/gradle-wrapper.properties

    distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

  3. 报错详情

    Cause: duplicate entry: META-INF/MANIFEST.MF

    Caused by: java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF
       at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:232)
       at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
       at com.android.builder.packaging.JarMerger.write(JarMerger.java:252)
       at com.android.builder.packaging.JarMerger.addJar(JarMerger.java:199)
       at com.android.builder.packaging.JarMerger.addJar(JarMerger.java:156)
       at com.android.build.gradle.internal.dependency.AarToClassTransform$Companion.copyEntryTo(AarToClassTransform.kt:94)
       at com.android.build.gradle.internal.dependency.AarToClassTransform$Companion.copyAllClassesJarsTo(AarToClassTransform.kt:90)
       at com.android.build.gradle.internal.dependency.AarToClassTransform$Companion.access$copyAllClassesJarsTo(AarToClassTransform.kt:83)
       at com.android.build.gradle.internal.dependency.AarToClassTransform.transform(AarToClassTransform.kt:78)
       at org.gradle.api.internal.artifacts.transform.DefaultTransformer.transform(DefaultTransformer.java:173)
       at
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':EasyAndroid:javaPreCompileDebug'.
    > Could not resolve all files for configuration ':EasyAndroid:debugCompileClasspath'.
      > Failed to transform artifact 'leakcanary-android-1.5.4.aar (:leakcanary-android-1.5.4:)' to match attributes {artifactType=android-classes, org.gradle.usage=java-api}.
         > Execution failed for AarToClassTransform: libs\leakcanary-android-1.5.4.aar.
            > duplicate entry: META-INF/MANIFEST.MF

你可能感兴趣的:(Android,android,MANIFEST.MF,编译异常,build,faild)