简体   繁体   English

升级 Android API Xamarin Forms 中的目标级别从 11 升级到 12

[英]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.我正在使用 Xamarin Forms,并且根据 Google Play 商店要求( https://developer.android.com/google/play/requirements/target-sdk )需要升级 Android 8838358 级别 1453向应用程序中使用的所有活动、服务和接收器添加了“已导出”标志。 Also updated the mutabality for PendingIntent flags.还更新了 PendingIntent 标志的可变性。 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. ~/Droid/obj/Debug/AndroidManifest.xml(5,5):错误 AMM0000:/~Droid/obj/Debug/lp/95/jl/AndroidManifest.xml 警告:命名空间'com.google.android.gms.analytics '用于:AndroidManifest.xml,AndroidManifest.xml。 android:exported needs to be explicitly specified for element <service#crc643a9353f6fb65c51a.FirebaseService>. android:需要为元素 <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.针对 Android 12 及更高版本的应用需要为android:exported指定一个明确的值,当相应的组件定义了一个 Intent 过滤器时。 See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.有关详细信息,请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported Directory 'obj/Debug/lp/95' is from 'Xamarin.GooglePlayServices.Analytics.Impl.dll'.目录“obj/Debug/lp/95”来自“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>. /~Droid/obj/Debug/AndroidManifest.xml(5,5):错误 AMM0000:android:需要为元素 <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.针对 Android 12 及更高版本的应用需要为android:exported指定一个明确的值,当相应的组件定义了一个 Intent 过滤器时。 See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.有关详细信息,请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported

/~Droid/obj/Debug/AndroidManifest.xml(5,5): Error AMM0000: android:exported needs to be explicitly specified for element <receiver#crc64df999be563077fc4.BootReceiver>. /~Droid/obj/Debug/AndroidManifest.xml(5,5):错误 AMM0000:android:需要为元素 <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.针对 Android 12 及更高版本的应用需要为android:exported指定一个明确的值,当相应的组件定义了一个 Intent 过滤器时。 See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.有关详细信息,请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported

Below are Nuget packages used in my application.以下是我的应用程序中使用的 Nuget 个包。

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.嗯,这对您不起作用的明确原因是因为您的 Firebase 图书馆,它们确实很古老。 I am surprised you still haven't faced any issues until Android 11.我很惊讶你在 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). 1.将目标 SDK 设置为 30(以消除 31+ 错误)。

2.Open application's manifest (AndroidManifest.xml) and click on "Merged Manifest" tab on bottom of your edit pane. 2.打开应用程序的清单 (AndroidManifest.xml) 并单击编辑窗格底部的“合并清单”选项卡。

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) 3.Go 到所有库的单独清单文件(如果创建了合并清单,则可以跳过此步骤,您可以直接查看合并清单)

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. 4.搜索是否有任何类型为活动、服务、接收器或提供者的条目没有导出属性,对于每个条目,请遵循下面的“修复找到的条目”部分。

5.Set target SDK back to 31 (or whatever it was before changing to 30). 5.将目标 SDK 设置回 31(或更改为 30 之前的任何值)。

For how to repair known errors(both android: exported="..." and tools: node="merge" are necessary), please refer to the following:已知错误的修复方法(android: exported="..." 和tools: node="merge" 都是必须的),请参考以下内容:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xamarin Forms 我的应用程序无法在 Android 12 上运行 - Xamarin Forms my app not working on Android 12 将 Xamarin.forms 应用程序上的目标框架从 Android 8.1 更改为 Android 9(对于 Xamarin.Essentials) - Changing target framework on Xamarin.forms app from Android 8.1 to Android 9 (for Xamarin.Essentials) Xamarin 表单连接到 Wifi &gt;= API 级别 29 - Xamarin Forms Connect to Wifi >= API Level 29 升级到Android 9后无法从Xamarin.Forms应用打开ESP32套接字 - Unable to open ESP32 socket from Xamarin.Forms app after upgrading to Android 9 当我们在 Xamarin.Forms Android 应用程序中将目标 API 版本更改为 26 时无法读取/写入文件 - Not able to Read/Write Files when we changed Target API Version to 26 in Xamarin.Forms Android Application 在Xamarin.Forms中使用Android支持库API Level 26(MonoAndroid 8.0 Oreo)? - Using android support libraries API Level 26 (MonoAndroid 8.0 Oreo) in Xamarin.Forms? Xamarin 启动画面 Android 11 VS Android 12 - Xamarin Splash Screen Android 11 VS Android 12 从Xamarin形式的Rest API检索数据 - retrieving data from rest api in xamarin forms 从 Xamarin.Z6450242531912981C3683CAE88A32A6 调用 Android Function - Call Android Function From Xamarin.Forms 从Xamarin表单启动Android服务 - Starting an android Service from Xamarin forms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM