PendingIntent

java.lang.IllegalArgumentException: cn.zherui.kuaigun.idea: 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:147)
    at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:124)
    at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:79)
    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)

Android 12为目标平台的App,在构建PendingIntent时,需要指定Flag为FLAG_IMMUTABLE(建议)或FLAG_MUTABLE二者之一
如果还是崩溃,缺少implementation 'androidx.work:work-runtime:2.7.1'

记录一下自己踩得坑,浪费我半天时间

你可能感兴趣的:(PendingIntent)