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"/>
Related Topics
Quaternion Rotation Does Not Work as Excepted
Android Emulator: How to Monitor Network Traffic
How to Add a Fast-Scroller to the Recyclerview
What Is the Use of the Res/Values/Public.Xml File on Android
Toolbar Overlapping Below Status Bar
Android Material: Status Bar Color Won't Change
How to Style the Standard React-Native Android Picker
Detect Touch Event on a View When Dragged Over from Other View
How to Change Textcolor in Alertdialog
How to Fix Error: No Signature of Method: Build_Ap86Oam3Dut3Pxce3X49Rdtma.Android()
Actionbaractivity Cannot Resolve a Symbol
How to Store a Boolean Value Using Sharedpreferences in Android
How to Use Tools:Overridelibrary in a Build.Gradle File
How to Receive Serial Data Using Android Bluetooth
Add Floating Point Value to Android Resources/Values
Differencebetween Background, Backgroundtint, Backgroundtintmode Attributes in Android Layout Xml
Apache Httpclient on Android Producing Certpathvalidatorexception (Issuername != Subjectname)