【发布时间】: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