본문 바로가기
프로그램 개발해서 돈벌기/Android

[Java] 안드로이드에서 크롬캐스트 연결 시 "전송 대상" 선택 후 앱 죽는 현상에 대한 해결 방법

by ubmuhan 2023. 6. 27.
반응형

안드로이드에서 크롬캐스트 연결 시 "전송 대상" 선택 후 앱 죽는 현상

디버깅을 해 보니 아래와 같은 에러 메시지가 보입니다. 

 

java.lang.IllegalArgumentException: com.kiwidisk.android: 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:382)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:660)
        at co m.google.android.gms.cast.framework.media.internal.zzm.zza(com.google.android.gms:play-services-cast-framework@@19.0.0:46) 
        at co m.google.android.gms.cast.framework.CastSession$zza.onResult(com.google.android.gms:play-services-cast-framework@@19.0.0:11) 
        at co m.google.android.gms.common.api.internal.BasePendingResult$CallbackHandler.handleMessage(com.google.android.gms:play-services-base@@17.1.0:11) 
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at co m.google.android.gms.internal.base.zar.dispatchMessage(com.google.android.gms:play-services-base@@17.1.0:8) 
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8751)
        at java.lang.reflect.Method.invoke(Native Method)
        at co m.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 
        at co m.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

 

 

문제는 크롬캐스트 버튼과 전송 대상 등 관련 화면은 모두 크롬캐스트에서 컨트롤합니다. 그래서 내가 FLAG_IMMUTABLE or FLAG_MUTABLE를 설정할 수 없었습니다.

 

내가 할 수 있는 건 크롬캐스트 라이브러리 버전을 높이는 방법 밖에 없었습니다.

 

<기존 크롬캐스트 버전>

implementation 'com.google.android.gms:play-services-cast-framework:19.0.0'

 

<신규 크롬캐스트 버전>

implementation 'com.google.android.gms:play-services-cast-framework:21.3.0'

 

크롬캐스트 라이브러리 버전을 바꾼 후 앱 종료 현상은 사라졌습니다.

 

 

 

 
반응형

댓글