GooglePlayServicesComponents
GooglePlayServicesComponents copied to clipboard
Exception java.lang.IllegalArgumentException: com.companyname.*: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Hi ,
We have upgraded the Android API Level 30 to API Level 31 to support the Android 12 Version in Xamarin Project. SDK Versions: Xamarin Forms:5.0.0.2401 Xamarin.Firebase.Messaging:71.1740 Xamarin.Android SDK-13.0.0
In the production we are getting the below issue even we add the Mutable FLAG'S.
Exception java.lang.IllegalArgumentException: com.companyname.*: 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.checkFlags (PendingIntent.java:375)
at android.app.PendingIntent.getActivityAsUser (PendingIntent.java:464)
at android.app.PendingIntent.getActivity (PendingIntent.java:444)
at android.app.PendingIntent.getActivity (PendingIntent.java:408)
at com.google.firebase.messaging.zza.zzh
at com.google.firebase.messaging.FirebaseMessagingService.zzd
at com.google.firebase.iid.zzg.run
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
at com.google.android.gms.common.util.concurrent.zza.run (com.google.android.gms:play-services-basement@@17.6.0:2)
at java.lang.Thread.run (Thread.java:1012)
we added the FLAG_IMMUTABLE for our PendingIntents see below
if (Build.VERSION.SdkInt >= BuildVersionCodes.S)
{
pendingIntent = PendingIntent.GetActivity(CrossCurrentActivity.Current.AppContext,
FormsActivity.NOTIFICATION_INTENT_ID,
intent,
PendingIntentFlags.Immutable);
}
else
{
pendingIntent = PendingIntent.GetActivity(CrossCurrentActivity.Current.AppContext,
FormsActivity.NOTIFICATION_INTENT_ID,
intent,
PendingIntentFlags.OneShot);
}
@anji22 Thanks for the feedback.
Why using nuget package that is more than 2 years old?
https://www.nuget.org/packages/Xamarin.Firebase.Messaging/71.1740.4
Try updating packages please.
We've encountered this issue with an old version of Firebase.Messaging (V.71.1740). Upgrading to the newest version (123.0.8) solved this problem, and we no longer see this exception. We've experienced no issues with older Android versions either.
This issue started when we moved from targeting Android API 30 to Android API 33, which means we used to build for Android 11 and only started seeing this when we started targeting Android 13.
I advise you to try updating your packages.
Hi TobiasJoergensen and moljac I already update Xamarin.Firebase.Messaging to latest version (123.1.2.2) but still got that issue. any solutions for that?