The build ends with 'Manifest merger failed' after raising targetSdk or adding an SDK
Manifest merger failed with multiple errors, see logsShort 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.
Fix it fast
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.txt2Match what you see, then jump to its fix
- 1
Apps 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
The 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
The report complains about uses-sdk and minSdk of a libraryA library needs a higher minSdk than your app declaresFix
- 1
What does the error look like?
Manifest merger failed with multiple errors, see logsManifest 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.xml2Fix
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 assembleDebugConfirmed by developer.android.com
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.txt2Fix
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 assembleDebugConfirmed by developer.android.com
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 assembleDebugConfirmed by developer.android.com
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 build stops at processDebugManifest in a React Native app
Manifest merger failed
processDebugManifest is the step that merges your AndroidManifest.xml with the manifests of every library.
2 causes, each with a fixMobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile 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 fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fix