0

When I update my Xamarin Android head to compile using Android 12, and change the minimal version to 10.0 and the target to 12.0, I get the following exception when the application starts:

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.

The stacktrace is

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)

Now my project contains no such PendingIntent so I am wondering what I should do.

  • Where is this pending intent being created in the stack? – Cheesebaron Jan 11 '22 at 08:32
  • No idea, its an Uno-Platform project. So I guess its being done in its internals. There is very little platform specific code – Patrick Decoster Jan 11 '22 at 08:52
  • So I would suggest you report an issue on the Uno repository. They would need to fix this issue. Unless it is fired in a method that can be overridden then you can't do much about it. – Cheesebaron Jan 11 '22 at 09:01
  • We don't seem to use `PendingIntent` anywhere in our repository directly, but it might be some dependency. Can you try updating all packages you reference to latest version? Especially AndroidX and Google Play ones (if any) - https://stackoverflow.com/questions/68228666/targeting-s-version-10000-and-above-requires-that-one-of-flag-immutable-or-fl . Also - does this happen for you with a blank Uno app as well? – Martin Zikmund Jan 11 '22 at 09:27
  • 1
    @MartinZikmun I just tried, and it doesn't happen with a blank app. I will go through the dependencies. – Patrick Decoster Jan 11 '22 at 09:35
  • Either way the stack trace for your exception will reveal what is causing it. – Cheesebaron Jan 11 '22 at 10:02
  • @Cheesebaron There is no stacktrace. It just shows `[External Code]` – Patrick Decoster Jan 11 '22 at 10:04
  • There is always a stack trace. Just keep pressing continue and check the debug output. – Cheesebaron Jan 11 '22 at 10:41
  • @Cheesebaron Ah, it showed up in the output panel (duh...) – Patrick Decoster Jan 11 '22 at 11:00
  • So are you using some plugin like Shiny or something like that to do background work? – Cheesebaron Jan 11 '22 at 12:57
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/240955/discussion-between-patrick-decoster-and-cheesebaron). – Patrick Decoster Jan 11 '22 at 12:57

1 Answers1

1

In this case adding the Xamarin.AndroidX.Work.Runtime NuGet package did the trick. In general this exception could mean a dependent package is not updated to support this Android 12 requirement.