Trying to update my application to Android S and running into some issues as the Title/error says. I get the error
Targeting S+ (version 10000 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.
I only have 1 PendingIntent within my code for notifications and I added the Flag
PendingIntent.getActivity( mContext, 0 /* Request code */, intentOptional.get(), PendingIntent.FLAG_IMMUTABLE )
Reading Google's documentation this should be all I need to for this security update within Android S. I did find a couple month old post on here that asked something similar and someone said to add WorkManager https://stackoverflow.com/a/67181567/4219444 into project even if you do not use it. So I added
def work_version = "2.7.0-alpha04" implementation "androidx.work:work-runtime-ktx:$work_version"
This didnt help at all as I still receive the error. Does anyone know if this is common issue with Android S upgrades or does it check libraries also? Stuck as the app just keeps crashing and not sure what to do.
I have created a application with none of my libraries and used the same PendingIntent and was able to run a basic hello world application with the pending intent. The full error I receive from the project I am trying to get to compile is:
Targeting S+ (version 10000 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 com.google.android.gms.internal.gtm.zzbv.zzfe(Unknown Source:52) at com.google.android.gms.internal.gtm.zzbv.cancel(Unknown Source:54) at com.google.android.gms.internal.gtm.zzbv.zzaw(Unknown Source:4) at com.google.android.gms.internal.gtm.zzan.zzag(Unknown Source:7) at com.google.android.gms.internal.gtm.zzap.(Unknown Source:67) at com.google.android.gms.internal.gtm.zzap.zzc(Unknown Source:82) at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source:15) at di.internal.module.ApplicationModule.providesGoogleAnalyticsLogger$app_developmentDebug(ApplicationModule.kt:339) at di.internal.module.ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.providesGoogleAnalyticsLogger$app_developmentDebug(ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.java:47) at di.internal.module.ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.get(ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.java:36) at di.internal.module.ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.get(ApplicationModule_ProvidesGoogleAnalyticsLogger$app_developmentDebugFactory.java:11) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at di.internal.module.ApplicationModule_ProvidesMultiAnalyticsLogger$app_developmentDebugFactory.get(ApplicationModule_ProvidesMultiAnalyticsLogger$app_developmentDebugFactory.java:35) at di.internal.module.ApplicationModule_ProvidesMultiAnalyticsLogger$app_developmentDebugFactory.get(ApplicationModule_ProvidesMultiAnalyticsLogger$app_developmentDebugFactory.java:10) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at di.internal.component.DaggerIProdApplicationComponent.injectChApplication(DaggerIProdApplicationComponent.java:941) 2021-07-02 11:18:17.611 22561-22561/com.chrobinson.navispherecarrier.dev E/AndroidRuntime: at di.internal.component.DaggerIProdApplicationComponent.inject(DaggerIProdApplicationComponent.java:876) at com.chrobinson.navispherecarrier.ChApplication.onCreate(ChApplication.kt:90) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6682)
FLAG_IMMUTABLE : Indicates the Intent inside the PendingIntent cannot be modified by other apps that pass an Intent to PendingIntent.send() . An app can always use FLAG_UPDATE_CURRENT to modify its own PendingIntents. Prior to Android 12, a PendingIntent created without this flag was mutable by default.
A PendingIntent itself is simply a reference to a token maintained by the system describing the original data used to retrieve it. This means that, even if its owning application's process is killed, the PendingIntent itself will remain usable from other processes that have been given it.
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. I have updated all PendingIntents in my App with the mutability flags.
It is solved by adding
implementation 'androidx.work:work-runtime:2.7.0-alpha05'
in my gradle. (You can add the latest release version of this library)
Seems like it is a bug in workmanager. Check the bug fix in Version 2.7.0-alpha02
https://developer.android.com/jetpack/androidx/releases/work#2.7.0-alpha02
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With