유니티/구글 에드몹

[유니티] 안드로이드 12 버전 에러 feat. 구글 애드몹

VicGameStudio_Choi 2022. 12. 1. 00:04

이번 시간에는 안드로이드 12 버전을 사용하면서.. 구글 애드몹도 같이 사용했을 때 발생하는 버그를 

알아보려고 한다. ㅎㅎ

 

이 버그를 어떻게 알게됬냐면.. 프로덕트로 출시한 앱이 검토되면서 몇몇 테스트 기기에서 버그가 발생한다는 것이었다;;

 

Exception java.lang.IllegalArgumentException: com.vicgamestudios.loadball: 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: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)

 

위 버그는 구글링으로 검색하면  FLAG_IMMUTABLE,  FLAG_MUTABLE 둘 중 하나를 선택해주어야 한다는 건데..

여튼.. 보통 이게 나오면.. 버전 31에서 애드몹 때문이라는 이유가 정설이다 ㅎㅎ

 

https://drybone-developer.tistory.com/109

 

[Unity] Android 12 이상 버전에서 앱 강제 종료 현상

이거 진짜... 길고 험난했다... API로 치면 31인가? 32? 어쨌든 안드로이드 버전 12가 나오면서 그 이전 버전을 대상으로 만든 유니티 프로젝트에서는 이거저거 바꿔주고 신경써야 할 게 늘었는데요

drybone-developer.tistory.com

 

나도 완전 똑같은 사례였는데, 친구 폰으로 실행 시, 실행하자마자 종료되는 현상이 발생했다..

위에 링크에서 빠진 내용은 Custom Gradle Properties Template도 체크해주어야한다;;

 

 

만들어진 mainTemplate 내에서 수정하면 된다.

 

dependency 내에 추가

 

 
2
3
4
5
6
7
8
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+.'''
   }
  }

 

참고로 Resolve 를 한 상태여야 한다는 것! 

 

'유니티 > 구글 에드몹' 카테고리의 다른 글

[구글 에드몹] 유니티 에드몹 사용법  (2) 2022.11.10