-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. #287
Comments
hi, any update on this? |
Hi @vinod-takhar , To resolve the IllegalArgumentException related to PendingIntent when targeting Android S+ (API level 31 and above), you need to specify either FLAG_IMMUTABLE or FLAG_MUTABLE when creating a PendingIntent. This change is required due to the updated security requirements in Android 12 (API level 31) and above. Here's a detailed explanation and steps to fix the issue: Explanation Steps to Fix Modify the PendingIntent Creation: Add either FLAG_IMMUTABLE or FLAG_MUTABLE to the PendingIntent creation. It's generally recommended to use FLAG_IMMUTABLE unless you specifically need the PendingIntent to be mutable. Here's how you can modify the code: Example Modification
After: PendingIntent pendingIntent = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_IMMUTABLE); Detailed Steps If you are using the Mapbox library and don't have direct control over the source code, check if there's an updated version of the library that addresses this issue. Find all instances where PendingIntent is created in your codebase. Ensure that all dependencies are up-to-date, as library maintainers may have already addressed this issue in newer releases. Example in Context // Locate where the PendingIntent is created and modify it This indicates that the PendingIntent creation in the Mapbox library (or possibly your code that interacts with it) does not specify the required flag. Additional Notes |
FATAL EXCEPTION: main
Process: com.hornblower.statuecruises, PID: 16525
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hornblower.statuecruises/com.hornblower.activity.ArActivityKt}: java.lang.IllegalArgumentException: com.hornblower.statuecruises: 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.ActivityThread.performLaunchActivity(ActivityThread.java:3802)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3942)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2448)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8194)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.IllegalArgumentException: com.hornblower.statuecruises: 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.checkPendingIntent(PendingIntent.java:450)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:753)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:740)
at com.mapbox.android.telemetry.AlarmSchedulerFlusher.register(AlarmSchedulerFlusher.java:31)
at com.mapbox.android.telemetry.MapboxTelemetry.startAlarm(MapboxTelemetry.java:394)
at com.mapbox.android.telemetry.MapboxTelemetry.startTelemetry(MapboxTelemetry.java:388)
at com.mapbox.android.telemetry.MapboxTelemetry.enable(MapboxTelemetry.java:132)
at com.mapbox.services.android.navigation.v5.navigation.NavigationMetricsWrapper.init(NavigationMetricsWrapper.java:30)
at com.mapbox.services.android.navigation.v5.navigation.NavigationTelemetry.initialize(NavigationTelemetry.java:124)
at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation.initializeTelemetry(MapboxNavigation.java:921)
at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation.initialize(MapboxNavigation.java:891)
at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation.(MapboxNavigation.java:121)
at com.hornblower.activity.ArActivityKt.startNavigation(ArActivity.kt:155)
at com.hornblower.activity.ArActivityKt.onPermissionsGranted(ArActivity.kt:92)
at com.hornblower.activity.ArBaseActivity.onCreate(ArBaseActivity.java:64)
at android.app.Activity.performCreate(Activity.java:8621)
at android.app.Activity.performCreate(Activity.java:8599)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3784)
... 12 more
The text was updated successfully, but these errors were encountered: