Manifest Merger Failed Targeting Android 12

Android Studio error: Manifest merger failed: Apps targeting Android 12

You need to specify android:exported="false" or android:exported="true"

Manifest:

<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>

as mentioned in the document:

If your app targets Android 12 and contains activities, services, or
broadcast receivers that use intent filters, you must explicitly
declare the android: exported attribute for these app components.

Warning: If an activity, service, or broadcast receiver uses intent
filters and doesn't have an explicitly-declared value for
android:exported, your app can't be installed on a device that runs
Android 12.

Also check when to use true/false for the 'android:exported' value.

Manifest merger failed targeting Android 12

The issue was caused by 3 activities missing the android:exported attribute in the androidx.test:core library version 1.3.0. Upgrading to version 1.4.0-beta01 fixed the issue.

If you are getting errors after targeting Android 12, the easiest way to debug this is to:

  • downgrade to a prior sdk version
  • rebuild project
  • after a successful build, open your project's AndroidManifest.xml.
  • at the bottom of the window, click on the Merged Manifest tab
  • look for any <activity> that includes an <intent-filter> tag and is missing the android:exported attribute

If you want to make sure these activities are the issue, add them directly to your project's AndroidManifest.xml file with the missing android:exported attribute added and try rebuilding the project.

So if <activity android:name="com.domain.ProblemActivity"> is missing the android:exported attribute, add it to your AndroidManifest.xml file like so:

<activity 
android:name="com.domain.ProblemActivity"
android:exported="true" >

Rebuild targeting Android 12 and if it works, then you found the bug!

Thanks @MikePenz for pointing me in the right direction.

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

  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.

Manifest merger failed with multiple errors | Android 12 and higher are required to specify an explicit value for `android:exported`

Your libraries are defining probably an "intent_filter" on an activity

debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

If your application is targeting API 31+, the attribute "exported" is mandatory.

So as the developer of that library didn't target API 31, the exported flag what not mandatory on his side. And he built it without exported attribute.

So what you can do, is redefine that specific class on your manifest to declare it explicitly exported or not. For example :

<activity android:name="com.squareup.leakcanary.internal.DisplayLeakActivity"
android:exported="true"/>


Related Topics



Leave a reply



Submit