简体   繁体   中英

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

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 包

Any suggestions on how to resolve this issue?

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

You can solve the problem by following the steps below:

1.Set target SDK to 30 (to silence 31+ errors).

2.Open application's manifest (AndroidManifest.xml) and click on "Merged Manifest" tab on bottom of your edit pane.

3.Go to the individual manifest file of all the libraries (You can skip this step if the merged manifest is created and you can just look into the merged manifest)

4.Search if there's any entry of type activity, service, receiver, or provider which does not have an exported attribute, and for each entry follow below "Fix found entries" section.

5.Set target SDK back to 31 (or whatever it was before changing to 30).

For how to repair known errors(both android: exported="..." and tools: node="merge" are necessary), please refer to the following:

<receiver
android:name=""
android:exported="false or true"
tools:node="merge" />

<Service
android:name=""
android:exported="false or true"
tools:node="merge" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM