【问题标题】:Xamarin.Android without the 'android:exported' property set errorXamarin.Android 没有“android:exported”属性设置错误
【发布时间】: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


【解决方案1】:

详细的输出 MSBuild 项目输出详细程度可以解决问题。

当我打开这个功能时,我发现了一个 NotificationPushService 和一个 TokenService 元素需要添加一个 android:exported="true" 标签。

【讨论】:

    猜你喜欢
    • 2021-02-24
    • 1970-01-01
    • 1970-01-01
    • 2021-03-10
    • 2020-07-09
    • 1970-01-01
    • 1970-01-01
    • 2020-12-11
    • 1970-01-01
    相关资源
    最近更新 更多