티스토리 뷰

728x90
반응형

Target Version을 31로 업데이트 해 보았다.

그랬더니 아래와 같은 오류가 발생하였다.

 

Fatal Exception: java.lang.IllegalArgumentException: com.example.app: 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:2)
       at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:15)
       at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java: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)

 

Target 31로 업데이트 후 PendingIntent를 실행하려 할 때 FLAG_IMMUTABLE 또는 FLAG_MUTABLE 무엇으로 실행 해 줄지 명시하라는 것이다. 

https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability

 

여기서 의문점은, 내가 실행한 앱에서 PendingIntent를 실행하는 부분이 없다는 것이었다.

그래서 좀 더 찾아보았다.

그 결과, 이 현상의 원인은 AdMob인 것을 알 수 있었다.

AdMob 20.4.0의 릴리즈 노트에는 아래와 같이 적혀 있었다.

 

This release and all previous versions require an explicit dependency on androidx.work:work-runtime:2.7.0 to fix a bug causing app crashes on Android S with the following stack trace:

Fatal Exception: java.lang.IllegalArgumentException:
com.mycompany.myapp: Targeting S+ (version 10000 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:386)
   at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:657)
   at android.app.PendingIntent.getBroadcast(PendingIntent.java:644)
   at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)
   at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108)
   at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86)
   at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
   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)

To fix this bug, add the following dependencies for the Google Mobile Ads SDK to your module's app-level Gradle file:

dependencies {
  implementation 'com.google.android.gms:play-services-ads:20.4.0'

  // For apps targeting Android 12, add WorkManager dependency.
  constraints {
    implementation('androidx.work:work-runtime:2.7.0') {
      because '''androidx.work:work-runtime:2.1.0 pulled from
      play-services-ads has a bug using PendingIntent without
      FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
      targeting S+.'''
    }
  }
}

https://developers.google.com/admob/android/rel-notes

 

그래서 아래와 같이 추가 해 줬다.

 

728x90
반응형
댓글