Search code examples
javaandroidandroid-manifest

Manifest merger failed : android:exported needs to be explicitly specified for <activity>


I have a problem with a manifest file, error message:

Manifest merger failed : android: exported needs to be explicitly specified for . 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. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

My AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyTheme">
        <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>
        <activity
            android:exported="true"
            android:name=".Activities.SplashScreenActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
        </activity>
    </application>

</manifest>

This post describes a solution but it doesn't work or I made something wrong. Maybe anyone has a similar problem, please let me know how to resolve that.


Solution

    1. downgrade or upgrade to a prior sdk version then rebuild the project.
    2. open your project's AndroidManifest.xml.
    3. click on the Merged Manifest tab [at the bottom of the window]
    4. find out which <activity> that includes an <intent-filter> tag is missing the android:exported attribute
    5. if found then right-click and press Go to Declaration then add android:exported attribute to the activity tag
    6. Rebuild the project

    Hope it will work. It works for me.