Android Studio Error: “manifest Merger Failed: Apps Targeting Android 12”

The error message "Manifest merger failed: Apps targeting Android 12" usually occurs when you try to build an Android app in Android Studio that targets Android 12 (API level 31) or higher. This error is often due to a conflict between your app’s manifest file and the new manifest changes introduced in Android 12.

To resolve this issue, you can try the following solutions:

  1. Update the Android Gradle Plugin: Make sure you are using the latest version of the Android Gradle Plugin (AGP) in your project’s build.gradle file. Open the file and check the classpath 'com.android.tools.build:gradle:xxx' line. Replace xxx with the latest version available.

  2. Check for conflicting attributes: The error message might provide you with information about the conflicting attributes causing the merger failure. Inspect the error message and review your app’s manifest file (AndroidManifest.xml) for any conflicting attributes. For example, make sure you are not using any deprecated or removed attributes specific to Android 12.

  3. Use the merge tool: If the conflicting attributes are not evident, Android Studio provides a convenient merge tool that can help you resolve manifest merger conflicts. To use the merge tool, go to the "Merged Manifest" tab in the Android Studio’s Manifest editor. This tab shows you the merged manifest file along with any conflicts. You can resolve the conflicts by selecting the desired value or attribute for each conflict.

  4. Update dependencies: Some third-party libraries or dependencies in your project might not be compatible with Android 12 yet. Ensure that you are using the latest versions of all dependencies and libraries and check their documentation for any updates specifically for Android 12 compatibility.

  5. Change targetSdkVersion and compileSdkVersion: Temporarily change the targetSdkVersion and compileSdkVersion in your app’s build.gradle file to a lower version (e.g., API level 30) that is already compatible with Android 12. This can help you identify specific issues related to the targeting of Android 12.

  6. Check Android Developer documentation: Keep in mind that Android 12 introduces some breaking changes and new features. Review the official Android Developer documentation for Android 12 and check if your app’s manifest and code contain any deprecated or removed features.

By applying these solutions, you should be able to resolve the "Manifest merger failed: Apps targeting Android 12" error and successfully build your Android app targeting Android 12.

About the Author Rex

I'm a passionate tech blogger with an insatiable love for programming! From my early days tinkering with code, I've delved into web dev, mobile apps, and AI. Sharing insights and tutorials with the world is my joy, connecting me to a global community of like-minded tech enthusiasts. Python holds a special place in my heart, but I embrace all challenges. Constantly learning, I attend tech conferences, contribute to open-source projects, and engage in code review sessions. My ultimate goal is to inspire the next generation of developers and contribute positively to the ever-evolving tech landscape. Let's code together!