【发布时间】:2022-06-30 04:24:28
【问题描述】:
当 Xamarin.Android 设置为 Android 12 时,我收到了
“您上传的 APK 或 Android App Bundle 具有 Activity, 带有意图过滤器的活动别名、服务或广播接收器,但是 没有 'android:exported' 属性集。这个文件不能 安装在 Android 12 或更高版本上。看: developer.android.com/about/versions/12/behavior-changes-12#exported"
将 APK 上传到 Google Play 控制台以获取新版本时出错。
我已将 Exported 属性添加到我的活动和服务中,但仍设置此错误。
[Activity(Label = "@string/AppDrawerName", Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_launcher_round", Theme = "@style/MainTheme", MainLauncher = true, Exported = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, ScreenOrientation = ScreenOrientation.Portrait)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
服务
[Service(Exported = true)]
public class BarcodeService : IBarcodeService
{
【问题讨论】:
-
试过设置为假吗?
-
没有帮助还是不行。我添加了 nuget,不知道这些 nuget 是否会添加任何未设置的活动或服务?
-
查看
obj/Debug/Android文件夹中生成的 AndroidManifest 并查看实际导出的内容 -
查看 obj/Debug/Android 中的输出清单文件,我发现带有“intent-filter”但没有设置“android:exported”的服务
标签: android xamarin xamarin.android android-12