Android Studio error Manifest merger failed Apps targeting Android 12
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When developing Android applications with Android Studio, one of the common errors that can occur during the merger of the AndroidManifest.xml files is: "Manifest merger failed: Apps targeting Android 12". To understand and resolve this error effectively, it's important to grasp both the context in which it appears and the mechanics of the manifest merger process.
Android Studio uses a Manifest Merger tool to merge the content from the main app’s AndroidManifest.xml file with the manifest files from included libraries and modules. During this process, conflicts or requirements imposed by new Android versions can cause errors.
Understanding the Error Context
The specific error "Manifest merger failed: Apps targeting Android 12" generally appears when an application is being updated or is targeting Android 12 (API level 31) or above, and the manifest file lacks essential configurations required by the newer Android versions. Starting from Android 12, Google introduced new privacy and security features that demand explicit declarations in the AndroidManifest.xml.
Key Requirements for Android 12 and Above
- Exported Attribute: Activities, services, or broadcast receivers that use intent filters must explicitly declare an
android:exportedattribute. This attribute specifies whether the component can be launched by components of other apps. - Notification Trampoline Restrictions: Android 12 imposes restrictions on launching activities from notifications, known as notification trampolines, to improve performance and prevent abuse.
Step-by-Step Fix for the Error
- Identify Affected Components: Check your AndroidManifest.xml and any manifests included from libraries for activities, services, or receivers with intent filters.
- Declare
android:exported: Add theandroid:exportedattribute to these components. Set it totrueif they should be accessible from other apps; otherwise,false.
- Update Dependencies: Ensure that all libraries and modules your app uses are compatible with Android 12. Update them if necessary.
- Compilation Target Update: Verify that your
compileSdkVersionandtargetSdkVersionin thebuild.gradle(Module: app) file are set to 31 or higher.
- Test Thoroughly: After making these changes, perform thorough testing to ensure that no functionality is broken, especially regarding components interacting with external apps.
Summary Table of Key Fixes
| Issue | Solution | Explanation |
Missing android:exported | Add android:exported="true/false" to <activity>, <service>, or <receiver> tags. | Required by Android 12 to explicitly declare component accessibility. |
| Notification Trampoline Issue | Adjust notification behaviors or use alternative methods like PendingIntent. | Android 12 restricts certain types of activities launched from notifications. |
| SDK Version Outdated | Update compileSdkVersion and targetSdkVersion in build.gradle to 31 or above. | Ensures compatibility with Android 12 and utilizes latest APIs. |
Additional Considerations
- Always refer to the official Android documentation when updating to newer SDKs as requirements can change.
- Consider the impact on users and how changes in manifest behavior could affect user experience or system functionality.
Understanding and resolving the "Manifest merger failed: Apps targeting Android 12" error involves checking and updating manifest declarations according to the newest Android requirements, ensuring a smooth development process when targeting the latest Android versions. Such proactive updates not only resolve errors but also leverage new platform features and enhancements to ensure robust and secure applications.

