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 theandroid: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
- downgrade or upgrade to a prior sdk version then rebuild the project.
- open your project's
AndroidManifest.xml
. - click on the Merged Manifest tab [at the bottom of the window]
- find out which
<activity>
that includes an<intent-filter>
tag is missing theandroid:exported
attribute - if found then right-click and press
Go to Declaration
then addandroid:exported
attribute to the activity tag - 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"/>
android:exported added but still getting error Apps targeting Android 12 and higher are required to specify an explicit value for android:exported
To solve this error in target sdk 31-
1.First of all set target sdk to 30
2.Then go to the merged manifest
3.Find if there’s any activity, service, receiver or provider that does not have android:exported
set.Override all those entries and set their android:exported
to true or false.
4.set target sdk back to 31 and run project
Related Topics
Singleton Class with Several Different Classloaders
Read the Output from Java Exec
Configuring Log4J Loggers Programmatically
How to Download Older Google Play Services
Code Will Only Return 0.0, 0.0 Gps Coordinate While Throwing Nullpointerexception
Java_Home Is Set to an Invalid Directory:
Android: Textview Automatically Truncate and Replace Last 3 Char of String
Android:Change App Label Programmatically
How to Make a Jtable Non-Editable
Remove Padding/Margin from Javafx Label
How Does Facebook Add Badge Numbers on App Icon in Android
Android Data Binding Using Include Tag
Sort Data to Recyclerview Based on Latest Date from Firebase