Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

2022. 7. 5. 20:34Android/Bug

java.lang.IllegalArgumentException: com.smg.nao: 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.c(Unknown Source:5)
	at androidx.work.impl.utils.ForceStopRunnable.d(Unknown Source:4)
	at androidx.work.impl.utils.ForceStopRunnable.run(Unknown Source:50)
	at androidx.work.impl.utils.f$a.run(Unknown Source:2)
	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)
S+(버전 31 이상)를 타겟팅하려면 PendingIntent를 생성할 때 FLAG_IMMUTABLE 또는 FLAG_MUTABLE 중 하나를 지정해야 합니다. FLAG_IMMUTABLE 사용을 강력히 고려하고 일부 기능이 변경 가능한 PendingIntent에 의존하는 경우에만 FLAG_MUTABLE을 사용하십시오. 인라인 회신이나 말풍선과 함께 사용해야 하는 경우.

 

해결방법 :

// 자바를 쓰는 경우
implementation 'androidx.work:work-runtime:2.7.1' 

// 코틀린을 쓰는 경우
implementation 'androidx.work:work-runtime-ktx:2.7.1'