일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- onScrollToIndexFailed
- 리액트 네이티브 헤르메스
- tsconfig baseurl
- 리액트네이티브 라이브러리 커스텀
- patch package
- Graveyard Keeper
- hermes engine
- Android
- RecyclerView
- react
- baseurl 오류
- Kotlin
- react native hook
- React Native
- ReactNative
- react native lodash
- 하우스플리퍼인테리어
- removeClippedSubviews
- unable to resolve module
- 하우스플리퍼
- 라이브러리 커스텀
- 헤르메스 엔진
- react native hooks
- 리액트 네이티브 ios
- 스팀게임추천
- privacy manifest
- 리액트네이티브 hooks
- 리액트네이티브
- react native privacy manifest
- 안드로이드
Archives
- Today
- Total
숨참고 개발다이브
[안드로이드/오류] 푸시 FirebaseMessagingService IllegalArgumentException 오류 본문
개발/Android
[안드로이드/오류] 푸시 FirebaseMessagingService IllegalArgumentException 오류
사라 Sarah 2022. 6. 6. 10:37728x90
AndroidRuntime: FATAL EXCEPTION: MQTT Rec: com.app.mobile-2e24ccbde048f2e91635651784
Process: com.app.mobile, PID: 17031
java.lang.IllegalArgumentException: com.app.mobile: 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 org.eclipse.paho.android.service.AlarmPingSender.start(AlarmPingSender.java:76)
at org.eclipse.paho.client.mqttv3.internal.ClientState.connected(ClientState.java:1150)
at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:987)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:118)
at java.lang.Thread.run(Thread.java:920)
이런 오류가 발생했다.
이유는 FirebaseMessagingService에서 pendingIntent를 설정할 때 FLAG_ONE_SHOT를 사용했기 때문이다.
기존에 사용하던 코드를 그대로 가져와 사용했더니 타겟 SDK가 32가 되면서 이런 오류가 발생하게 되었다.
해결방법
build.gradle(app) 에 다음을 추가하면 된다.
dependencies {
// Java
implementation 'androidx.work:work-runtime:2.7.1'
// Kotlin
implementation 'androidx.work:work-runtime-ktx:2.7.1'
}
해당 코드를 추가해도 오류가 발생한다면 pendingIntent에 Flag를 수정해주어야 한다.
FLAG_IMMUTABLE 혹은 FLAG_MUTABLE로 교체해주면 된다.
PendingIntent의 Flag 속성은 다음과 같다.
FLAG_CANCEL_CURRENT : 이전에 생성한 PendingIntent를 취소하고 새로 생성한다.
FLAG_IMMUTABLE : PendingIntent는 변경 불가능하도록 설정한다.
FLAG_MUTABLE : PendingIntent가 변경 가능하도록 설정한다.
FLAG_NO_CREATE : PendingIntent가 존재한다면 재사용을, 존재하지 않으면 null을 리턴한다.
FLAG_ONE_SHOT : 일회성 PendingIntent이다.
FLAG_UPDATE_CURRENT : PendingIntent가 존재하면 기존 PendingIntent를 유지하고 Extra Data만 변경해준다.
공식 문서에서도 다음과 같이 속성 확인이 가능하다.
300x250
'개발 > Android' 카테고리의 다른 글
[안드로이드/kotlin] 카카오톡 채널 연결하기(채널 추가하기, 채널 채팅하기) (0) | 2022.06.07 |
---|---|
[안드로이드/오류] API 통신 시 발생하는 SocketTimeoutException (0) | 2022.06.06 |
[안드로이드/kotlin] 특정 날짜까지 남은 시간 타이머 만들기(CountDownTimer) (0) | 2022.05.31 |
[안드로이드/kotlin] ViewTreeObserver로 View의 크기 구하기 (0) | 2022.05.30 |
[안드로이드/Kotlin] RecyclerView를 이용한 GridView 생성하기 (GridLayoutManager) (0) | 2022.05.26 |
Comments