【问题标题】:Where do I put FLAG_IMMUTABLE or FLAG_MUTABLE for Android 12 head?Android 12 头部的 FLAG_IMMUTABLE 或 FLAG_MUTABLE 应该放在哪里?
【发布时间】:2022-01-11 08:27:14
【问题描述】:

当我更新我的 Xamarin Android 头以使用 Android 12 进行编译,并将最低版本更改为 10.0 并将目标更改为 12.0 时,应用程序启动时出现以下异常:

Java.Lang.IllegalArgumentException: '[Package Name]: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

堆栈跟踪是

at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:196)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:128)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:93)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)

现在我的项目不包含这样的PendingIntent,所以我想知道我应该怎么做。

【问题讨论】:

  • 这个待处理的 Intent 在堆栈中的哪个位置创建?
  • 不知道,这是一个 Uno-Platform 项目。所以我猜它是在它的内部完成的。平台特定代码很少
  • 所以我建议你在 Uno 存储库上报告一个问题。他们需要解决这个问题。除非它是在一个可以被覆盖的方法中触发的,否则你无能为力。
  • 我们似乎没有直接在我们的存储库中的任何地方使用PendingIntent,但这可能是一些依赖。您可以尝试将您引用的所有软件包更新为最新版本吗?特别是 AndroidX 和 Google Play 的(如果有的话) - stackoverflow.com/questions/68228666/… 。另外 - 空白的 Uno 应用也会发生这种情况吗?
  • @MartinZikmun 我刚试过,空白应用程序不会发生这种情况。我将通过依赖关系。

标签: android xamarin uno-platform


【解决方案1】:

在这种情况下,添加 Xamarin.AndroidX.Work.Runtime NuGet 包就可以了。通常,此异常可能意味着未更新依赖包以支持此 Android 12 要求。

【讨论】:

  • 我需要初始化这个包吗?我试过这个,将它添加到我的 xamarin.androi 项目中,但它没有用。
猜你喜欢
  • 2022-09-29
  • 2022-01-04
  • 2020-03-12
  • 2022-07-09
  • 2021-11-03
  • 2012-02-17
  • 2018-11-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多