androidin-app-updategoogle-play-coreandroid-api-31

FakeAppUpdateManager - No longer working on API 31+, does not specify mutability flag when creating PendingIntent, when fetching appUpdateInfo


Using PlayCoreKtx version 1.8.1,

I have an instrumented test that tests the inAppUpdate functionality of Play Core. I have a function in my test that looks like this

private fun processAvailableUpdate(appUpdateType: AppUpdateType) = mainActivityScenario.onActivity { mainActivity ->
    AppUpdater.processAvailableUpdate(
        mainActivity,
        AppUpdateResult.Available(
            fakeAppUpdateManager,
            Tasks.await(fakeAppUpdateManager.appUpdateInfo)
        ), appUpdateType
    )
}

I am getting the following exception on the line

Tasks.await(fakeAppUpdateManager.appUpdateInfo)

java.lang.IllegalArgumentException: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

I assume there is no going around this until it is fixed in the PlayCore library? Unless I am missing something.

Thanks for the help


Solution

  • Turns out the issue is fixed in

    com.google.android.play:core:1.10.3
    

    If you only had

    com.google.android.play:core-ktx:1.8.1
    

    in your dependencies, then you had this error. So make sure to add both dependencies to your gradle file.