Entry name 'AndroidManifest.xml' collided (Build failed after updating the android gradle plugin to 3.6.0)

前端 未结 6 1505
囚心锁ツ
囚心锁ツ 2021-02-04 02:02

I have recently updated the Android Studio from 3.5(stable) to 3.6(stable).

Then I saw the plugin update was also available, so I have updated the version of "com.an

相关标签:
6条回答
  • 2021-02-04 02:28

    I had the same issue with AndroidManifest.xml files colliding. First, I tried the useNewApkCreator workaround and it worked on the app variant I was working on. But when I switched to another variant, build was still successful but the app refused to install from Android Studio. Also installing the .apk manually gave parsing error on the device.

    Finally, I analyzed the .apks from both variants and noticed that the broken .apk had the wrong AndroidManifest.xml in it. Excluding the manifest in packagingOptions worked though.

    0 讨论(0)
  • 2021-02-04 02:30

    I found a workaround by adding this to the app's build.gradle:

    android {
        packagingOptions {
            exclude 'AndroidManifest.xml'
        }
    }
    

    I had this to fix an issue with creating a bundle, due to Facebook's Audience Network, on Android Studio 3.5.

    0 讨论(0)
  • 2021-02-04 02:34

    There are few methods to resolve this issue.

    1. Revert build.gradle version to 3.5.3

      dependencies {
             // classpath 'com.android.tools.build:gradle:3.6.1'       
                classpath 'com.android.tools.build:gradle:3.5.3'
              }
      
    2. Add packagingOptions under app/build.gradle

      android {
         ...
      
        packagingOptions {
            exclude 'AndroidManifest.xml'
        }
      
       }
      
    3. Under gradle.properties, set useNewApkCreator to false. Adding this flag might cause some apk installation issues.

      android.useNewApkCreator=false
      

    Final approach, perform a scan through third-party library. Check for androidx.core:core-ktx plugin. Try to update to 1.2.0 or newer version.

    0 讨论(0)
  • 2021-02-04 02:34

    According to the issue this happens when a JAR dependency contains an AndroidManifest.xml file.

    For my project, the cause was this old dependency:

    androidTestImplementation 'com.google.android:android-test:4.1.1.4' 
    

    Which had a dependency on com.google.android:android:4.1.1.4 which had an AndroidManifest.xml in the JAR.

    How I found it

    I searched in $HOME\.gradle\caches\modules-2\files-2.1 for all .jar files containing an AndroidManifest.xml (I used Total Commander)

    Then I cross referenced the results with the dependencies of my app. To get the dependency tree use the Gradle tool window to run the Tasks/android/androidDependencies gradle task.

    0 讨论(0)
  • 2021-02-04 02:40

    I get a similar error: Entry name 'resources.arsc' collided. Workaround as @Marco Batista said:

    android {
        packagingOptions {
            exclude 'resources.arsc'
        }
    }
    
    0 讨论(0)
  • 2021-02-04 02:48

    This is caused by Android Gradle plugin 3.6, revert to using the old packaging tool by including the following in your gradle.properties file will fix this:

    android.useNewApkCreator=false
    

    More info please check the release note: https://developer.android.com/studio/releases/gradle-plugin#zipflinger

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