Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manifest merger failed for <receiver> when migrating to android 12 despite adding android: exported flag

I am trying migrating my app to android 12 by changing the target SDK version to 31 in build.gradle. As required, I have added android:exported flag to every activity/receiver/services/provider tags present in my manifest file. But still I am getting this error.

Manifest merger failed : android:exported needs to be explicitly specified for <receiver>. 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.

So I am guessing this issue is due to any 3rd party library whose manifest contains a receiver without android:exported flag.

I have also checked merged manifest file for missing android:exported in components of any third party libraries. But in merged manifest file also all activity/receiver/services tags has exported flag.

So how can I find that missing receiver which is causing the issue.

like image 984
akhil jain Avatar asked Oct 19 '25 02:10

akhil jain


1 Answers

The reason is because some of the dependency libraries that you're using have elements which do not have "android:exported" attribute.

You need to do this:

  • Lower the version in your gradle to 30 and sync and build.
  • Go to your AndroidManifest.xml file and click on "Merged Manifest".
  • Find items that don't have "android:exported" attribute.
  • Then add them to your AndroidManifest.xml file in this way.
<activity
    android:name="SomeActivity"
    android:exported="false"
    tools:node="merge"
    tools:replace="android:exported" />

Now you can increase your version to 31.

like image 151
Harry Avatar answered Oct 21 '25 14:10

Harry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!