3

I recently updated my app to target API 31 and have noticed a new crash being reported in the Google Play Console that makes no sense to me.

The crash caused by exception.class.missing._Unknown_: Strongly consider using FLAG_IMMUTABLE... for which there are a number of answers on SO and elsewhere, however from what I have read this crash should be related to use of PendingIntent only.

The crash reports make sense in that I have only seen the crash reported on Android 12 (API 31) as this is where the explicit IMMUTABLE or MUTABLE requirement was introduced, but I have searched the whole of my project and cannot find any use of PendingIntent.

The timing of the crashes appears to tie in with an FCM push notification I sent, which again ties in with the crash coming from PendingIntent, but if I cannot find that in my source then how can I explicitly set FLAG_IMMUTABLE?

My project dependencies are as below:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.4.0-beta01'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'

    // billing for in-app purchases
    implementation 'com.android.billingclient:billing:3.0.2' 

    // For in-app review flow
    implementation 'com.google.android.play:core:1.10.2'

    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:26.1.1')
    implementation 'com.google.firebase:firebase-messaging'

}
Fat Monk
  • 2,077
  • 1
  • 26
  • 59
  • 1
    Got exact same issue. Not using any pending intent either. Have not had time to look into it yet though – Sermilion Nov 09 '21 at 19:52
  • Well I'm pleased it's not just me, but I'm struggling to investigate because the only Android 12 device 8 have is in the emulator and that doesn't even seem to want to receive FCM push notifications at the moment so I'll need to fix that first. Would be good to know what you find when you do get a chance to investigate - I'm afraid to send notifications to my app at the moment because of the crash. – Fat Monk Nov 09 '21 at 21:01

1 Answers1

1

This is a known issue with Admob, as mentioned at https://developers.google.com/admob/android/quick-start

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+.

The solution is also mentioned, in the app/build-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+.'''
        }
      }
    }
Mohan Noone
  • 561
  • 6
  • 14
  • 1
    Interesting, but my app doesn't use AdMob, so the crash is not coming from there. – Fat Monk Nov 10 '21 at 08:55
  • I've added the dependencies from my build.gradle to the question. I wonder if something else that I am using has the same issue that the AdMob code does.... – Fat Monk Nov 10 '21 at 10:08
  • Could try tagging the constraints section under dependencies: 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+.''' } } – Mohan Noone Nov 11 '21 at 05:14
  • Could try *adding :) – Mohan Noone Nov 11 '21 at 05:26
  • I'm hoping to try that, but testing is an issue. I need to work out why my Android 12 emulator isn't receiving notifications and then replicate the problem there (along with creating a test notification category so as not to affect actual users)... It's difficult to test if this fixes when I can't replicate on my test AVD. – Fat Monk Nov 11 '21 at 08:10
  • That is a problem... however, the error messages are identical, so if nothing else is found, I think worth a try! – Mohan Noone Nov 11 '21 at 17:00