AGP 7.3.1 manifest merger failed

Issue

After updating to Android Gradle Plugin 7.3.1 Android Studio says that package is deprecated in AndroidManifest.xml and I need to use namespace param in build.gradle.kts. I removed the package attribute in all my android manifests (I’m using additional manifest files for debug and release builds) and have done this:

build.gradle.kts

android {
    ...
    applicationId = "org.sample.appid"
    ...
    namespace = "org.sample.packageid"
    ...
}

After this I can not build the project because of the error:

D:\Desktop\Sample\app\src\debug\AndroidManifest.xml:4:5
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : Attribute manifest@package value=(org.sample.packageid) from AndroidManifest.xml:4:5-35
    is also present at AndroidManifest.xml:2:1-102:12 value=(org.sample.appid).
    Attributes of <manifest> elements are not merged.

Debug manifest can not be merged with the main manifest, but why package name is mixed with applicationId while merging? Is there anything that must be additionally configured? Or there’s a bug with AGP 7.3.1?

Solution

The problem was really complex – I missed removing the package attribute in one AndroidManifest.xml. Also, Android Studio must be restarted after that with a full cache clear (without this it will not work). After that everything works as expected.

Answered By – don11995

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *