Maaz Zindani

Loading the index…

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

The build ends with 'Manifest merger failed' after raising targetSdk or adding an SDK

ErrorManifest merger failed with multiple errors, see logs

Short answer

The merger could not combine your AndroidManifest.xml with the manifests of your libraries. Open the merger report in build/outputs/logs: it lists each error with the file and line. The usual three are a missing android:exported on a component with an intent filter, two files setting one attribute differently, and a library that needs a higher minSdk.

  • Applies to Android Gradle plugin 8.x, Gradle 8.x, targetSdk 31 and higher
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Build the debug variant with a stack trace, then read the merger report. Each ERROR line in it names one conflict and the manifest it came from.

    ./gradlew assembleDebug --stacktrace
    grep -n "ERROR" app/build/outputs/logs/manifest-merger-debug-report.txt
  2. 2Match what you see, then jump to its fix

    1. 1Apps targeting Android 12 and higher are required to specify an explicit value for android:exportedA component with an intent filter has no android:exported valueFix
    2. 2The report shows an attribute (for example android:allowBackup or android:theme) present in two manifests with different valuesYour manifest and a library set the same attribute to different valuesFix
    3. 3The report complains about uses-sdk and minSdk of a libraryA library needs a higher minSdk than your app declaresFix

What does the error look like?

  • Manifest merger failed with multiple errors, see logs
  • Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined.

Cause 1 of 3

A component with an intent filter has no android:exported value

1Check

Since targetSdk 31, every activity, service and receiver that has an intent filter must say android:exported. The component may be in your own manifest or in a library, so open the merged manifest tab in Android Studio and look for the element the report names.

grep -n -B2 -A6 "intent-filter" app/src/main/AndroidManifest.xml

2Fix

Add android:exported to each such component in your manifest. Use true for the one with the LAUNCHER category and false for most others. If the element comes from a library you cannot change, redeclare it in your manifest with the value and tools:replace.

<activity
    android:name=".MainActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

3Verify

Build again. The android:exported error is gone from the report.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

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

1Check

When both files declare an attribute with different values, the merger stops. Your own manifest has the higher priority, so you decide which value wins.

grep -n "ERROR" app/build/outputs/logs/manifest-merger-debug-report.txt

2Fix

Declare the tools namespace in your manifest and name the attribute in tools:replace. Your value is then kept. Use tools:remove if you want the library value dropped instead.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <application
        android:allowBackup="false"
        tools:replace="android:allowBackup" />
</manifest>

3Verify

Rebuild and open the Merged Manifest tab: the attribute shows your value.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

A library needs a higher minSdk than your app declares

1Check

The merger raises an error when a library manifest has a higher minSdk than yours. Compare your minSdk with the one the library documents.

grep -rn "minSdk" app/build.gradle*

2Fix

The clean fix is to raise minSdk in build.gradle. If you accept that the library may fail on older devices, list its package in tools:overrideLibrary in the uses-sdk element instead.

// app/build.gradle.kts
android {
    defaultConfig {
        minSdk = 24
    }
}

<!-- or, in AndroidManifest.xml -->
<uses-sdk tools:overrideLibrary="com.example.lib1" />

3Verify

The build passes the manifest step.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Set android:exported on every component with an intent filter the moment you raise targetSdk.
  • Read the merger report whenever you add an SDK; it shows what that SDK put into your manifest.
  • Keep minSdk and targetSdk only in build.gradle, not in a uses-sdk element.

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

Next step

Want this handled for good?

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