Issue
I'm developing a system app, and when I attempt to start it up from the home screen in Android 31, it fails and an java.lang.IllegalArgumentException
is thrown. Here's what the stack trace looks like:
java.lang.IllegalArgumentException: tech.[brand].[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:285)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:158)
at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(ForceStopRunnable.java:185)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:103)
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)
The stack doesn't reach any of my source code and far as I know I'm not calling any intent in my code so far, pending or otherwise. Does anyone know what's going on?
Solution
The androidx.work
in the stack trace is WorkManager
. As per the WorkManager 2.7.0-alpha02:
Make PendingIntent mutability explicit, to fix a crash when targeting Android 12.
Therefore you should upgrade to the latest version, WorkManager 2.7.1 by adding an explicit dependency on that latest version to the dependencies
block of your build.gradle
file:
implementation "androidx.work:work-runtime:2.7.1"
Answered By - ianhanniballake
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.