Recently we released android application targets to 31 which has reported more crashes (only Android OS 12 users) in Firebase Messaging (PendingIntent). When Application is in Pause/Background state on Notification Receive its crashing. I've tried possible solutions but no luck still crashing. As i understood is we have to add PendingIntent.FLAG_IMMUTABLE on PendingIntent start activity but not getting any idea how to add or fix this.
If anyone faced same issue and fixed. Share solution for this.
Thanks in advance...
dependencies{
implementation platform('com.google.firebase:firebase-bom')
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-iid'
implementation 'com.google.firebase:firebase-analytics:17.4.4'
implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
}
E/AndroidRuntime( 7058): java.lang.IllegalArgumentException: com.package: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime( 7058): 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.
E/AndroidRuntime( 7058): at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/AndroidRuntime( 7058): at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
E/AndroidRuntime( 7058): at android.app.PendingIntent.getActivity(PendingIntent.java:444)
E/AndroidRuntime( 7058): at android.app.PendingIntent.getActivity(PendingIntent.java:408)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.CommonNotificationBuilder.createContentIntent(com.google.firebase:firebase-messaging@@20.3.0:125)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.CommonNotificationBuilder.createNotificationInfo(com.google.firebase:firebase-messaging@@20.3.0:27)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.CommonNotificationBuilder.createNotificationInfo(com.google.firebase:firebase-messaging@@20.3.0:9)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.DisplayNotification.handleNotification(com.google.firebase:firebase-messaging@@20.3.0:27)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(com.google.firebase:firebase-messaging@@20.3.0:65)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@20.3.0:44)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@20.3.0:27)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@20.3.0:17)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(com.google.firebase:firebase-messaging@@20.3.0:43)
E/AndroidRuntime( 7058): at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)
E/AndroidRuntime( 7058): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime( 7058): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime( 7058): at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@17.6.0:2)
E/AndroidRuntime( 7058): at java.lang.Thread.run(Thread.java:920)
W/CrashlyticsCore( 7058): Cannot send reports. Settings are unavailable.
D/TransportRuntime.SQLiteEventStore( 7058): Storing event with priority=HIGHEST, name=FIREBASE_CRASHLYTICS_REPORT for destination cct