[FIXED] Upgrading Android API Target level to 12 from 11 in Xamarin Forms

Issue

I’m using Xamarin Forms, and as per the Google Play store requirements(https://developer.android.com/google/play/requirements/target-sdk) need to upgrade Android SDK level from 11 to 12. I’ve added "Exported" flags to all of the activities, services and receivers used in the application. Also updated the mutabality for PendingIntent flags. But, when I run the application I’m getting errors.

~/Droid/obj/Debug/AndroidManifest.xml(5,5): Error AMM0000: /~Droid/obj/Debug/lp/95/jl/AndroidManifest.xml Warning:
Namespace ‘com.google.android.gms.analytics’ used in: AndroidManifest.xml, AndroidManifest.xml.
android:exported needs to be explicitly specified for element <service#crc643a9353f6fb65c51a.FirebaseService>. 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.
Directory ‘obj/Debug/lp/95’ is from ‘Xamarin.GooglePlayServices.Analytics.Impl.dll’.

/~Droid/obj/Debug/AndroidManifest.xml(5,5): Error AMM0000:
android:exported needs to be explicitly specified for element <service#crc643a9353f6fb65c51a.FirebaseIdService>. 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.

/~Droid/obj/Debug/AndroidManifest.xml(5,5): Error AMM0000:
android:exported needs to be explicitly specified for element <receiver#crc64df999be563077fc4.BootReceiver>. 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.

Below are Nuget packages used in my application.

Nuget packages

Any suggestions on how to resolve this issue?

Solution

Well the clear-cut reason this is not working for you is because of your Firebase libraries, They are literally ancient. I am surprised you still haven’t faced any issues until Android 11.

The best way to fix this is to upgrade the following libraries to at least these versions:

Xamarin.Firebase.Analytics 120.0.1
Xamarin.Firebase.Analytics.Impl 116.3.0
Xamarin.Firebase.Messaging 123.0.3

Goodluck

Feel free to get back if you have queries

Answered By – FreakyAli

Answer Checked By – Terry (FixeMe Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *