Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Manifest merge fails because a library sets the same attribute as your app

ErrorManifest merge conflict on the application element

Short answer

The manifest merger fails when your app and a library give the same attribute different values, such as android:icon on application. Put tools:replace naming every conflicting attribute on that element in your app manifest, the higher-priority file, and declare the tools namespace there.

  • Applies to Android Gradle Plugin 8.x, Android Studio
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the merge report for the failing variant. It names the attribute and the library manifest that conflicts.

    cat app/build/outputs/logs/manifest-merger-debug-report.txt
  2. 2Match what you see, then jump to its fix

    1. 1The report shows the same attribute on application from two files, one of them a libraryYour app and a library set the same attribute to different valuesFix
    2. 2After adding tools:replace the build fails again, now naming another attribute such as android:label or android:themeThe marker lists only one of several conflicting attributesFix
    3. 3tools:replace is present but the conflict is unchangedThe marker is in the wrong manifestFix

What does the error look like?

  • Manifest merge conflict on the application element
  • Conflict error shown under Merging Errors in the Merged Manifest view
  • The same attribute, for example android:icon, appears in your manifest and in a library manifest with different values

Cause 1 of 3

Your app and a library set the same attribute to different values

1Check

The merger combines manifests by priority. If both set the attribute and the values differ, it is a conflict you must resolve with a merge rule marker. The Merged Manifest tab in Android Studio shows the same conflict with a suggested marker.

grep -n "android:icon\|android:label\|android:theme" app/src/main/AndroidManifest.xml

2Fix

Add the tools namespace to the manifest element and add tools:replace on application with the attribute names, comma separated. Your app's values are kept.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        tools:replace="android:icon">
    </application>
</manifest>

3Verify

Build the variant and open the merged manifest.

./gradlew :app:assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

The marker lists only one of several conflicting attributes

1Check

A marker accepts one or more attribute names including the namespace, separated by commas. An attribute that is not listed still conflicts.

grep -n "conflict\|Conflict" app/build/outputs/logs/manifest-merger-debug-report.txt

2Fix

List every attribute that the report names as conflicting, each with its android: prefix.

tools:replace="android:icon,android:label,android:theme"

3Verify

Rebuild; the report should show no conflict left on application.

./gradlew :app:assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

The marker is in the wrong manifest

1Check

The merger looks for markers in the higher-priority manifest. Priority runs: build variant manifest, main app manifest, then libraries. A marker placed in a library manifest, or in a lower-priority source set, is not consulted for that merge.

find . -name AndroidManifest.xml -not -path "*/build/*"

2Fix

Move the marker into the app's main manifest, or into the variant or flavor manifest that outranks the file you want to override.

app/src/main/AndroidManifest.xml

3Verify

Rebuild and read the merge report again.

./gradlew :app:assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Open the Merged Manifest tab after adding a library and fix conflicts in the app manifest straight away.
  • Set the application attributes your app needs explicitly instead of relying on defaults.
  • Keep tools merge markers narrow: name only the attributes that really conflict.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.