Manifest Merger Failed in Android 12 Targeted Apps: Comprehensive Analysis of android:exported Attribute and Solutions

Nov 18, 2025 · Programming · 13 views · 7.8

Keywords: Android 12 | Manifest Merger | android:exported | Intent Filter | Security

Abstract: This article provides an in-depth analysis of the 'Manifest merger failed' error in Android 12 and higher versions, detailing the mechanism, configuration requirements, and security significance of the android:exported attribute. Through complete code examples and step-by-step solutions, it helps developers understand and fix this common build error, ensuring compliance with Android 12's new security specifications.

Problem Background and Error Analysis

With the release of Android 12 (API level 31), Google introduced stricter security requirements, particularly regarding external access control for application components. When developers upgrade their app's target SDK version to Android 12, they frequently encounter the following build error:

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.

This error occurs during the manifest merging phase of the Gradle build process, indicating that there are activity, service, or broadcast receiver components in the application manifest that do not comply with the new specifications.

Detailed Explanation of android:exported Attribute

The android:exported attribute is a key element in the Android manifest file that defines whether a component allows access from external applications. Prior to Android 12, this attribute could be implicitly inferred in certain scenarios, but starting from Android 12, all components containing intent filters must explicitly declare this attribute.

The two possible values for this attribute and their meanings:

Solutions and Code Implementation

To resolve this issue, you need to explicitly add the android:exported attribute to all components containing intent filters in the AndroidManifest.xml file. Here is a complete fix example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:theme="@style/Theme.MyApplication.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        
        <service
            android:name=".MyService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.example.myapplication.MY_ACTION" />
            </intent-filter>
        </service>
        
    </application>
</manifest>

Attribute Configuration Decision Guide

Proper configuration of the android:exported attribute requires consideration of the component's actual usage scenarios:

Cases for setting to true:

Cases for setting to false:

Security Impact and Best Practices

This change in Android 12 significantly enhances application security. By forcing explicit declaration of export status, it can:

When migrating to Android 12, developers are advised to conduct security audits of all components to ensure only necessary components are exported.

Special Considerations for Cross-Platform Frameworks

For developers using cross-platform frameworks like Ionic and Cordova, this issue may appear in plugin configurations or framework-generated manifest files. It's necessary to check:

By manually adjusting manifest files or updating relevant plugin versions, cross-platform applications can also comply with Android 12 requirements.

Testing and Verification

After fixing, comprehensive testing should be conducted to ensure:

Using Android Studio's Lint tool can automatically detect potential manifest configuration issues.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.