0

When i run the application android OS 11 and below it is working but it not working Android os 12 when i deploy the application the following run time exception im getting.

[AndroidRuntime] 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.
[AndroidRuntime]    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
[AndroidRuntime]    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:651)
[AndroidRuntime]    at android.app.PendingIntent.getBroadcast(PendingIntent.java:638)
[AndroidRuntime]    at com.google.firebase.iid.zzl.zzd(Unknown Source:18)
[AndroidRuntime]    at com.google.firebase.iid.zzl.zzb(Unknown Source:229)
[AndroidRuntime]    at com.google.firebase.iid.zzl.zza(Unknown Source:0)
[AndroidRuntime]    at com.google.firebase.iid.zzj.zzb(Unknown Source:41)
[AndroidRuntime]    at com.google.firebase.iid.zzj.getToken(Unknown Source:56)
[AndroidRuntime]    at com.google.firebase.iid.FirebaseInstanceId.getToken(Unknown Source:10)
[AndroidRuntime]    at com.google.firebase.iid.FirebaseInstanceId.zzcfy(Unknown Source:4)
[AndroidRuntime]    at com.google.firebase.iid.FirebaseInstanceIdService.zza(Unknown Source:148)
[AndroidRuntime]    at com.google.firebase.iid.FirebaseInstanceIdService.handleIntent(Unknown Source:122)
[AndroidRuntime]    at com.google.firebase.iid.zzc.run(Unknown Source:4)
[AndroidRuntime]    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
[AndroidRuntime]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
[AndroidRuntime]    at java.lang.Thread.run(Thread.java:1012)

Kindly help on this.

neha
  • 65
  • 8

2 Answers2

0

At first, you can debug to find which PendingIntent you used caused this error.

If it is created by yourself, you can try to set the flag as PendingIntentFlags.Immutable or the PendingIntentFlags.UpdateCurrent when you use the PendingIntent. For more information, you can check this case.

And if it is created by the nuget packages you used, you can try to upgrade the package's version to the newest one.

In addition, the library mentioned in the case's answer I provided above. It is the nuget package named Xamarin.AndroidX.Work.Runtime in the xamarin, you can install the last version in your project.

Liyun Zhang - MSFT
  • 8,271
  • 1
  • 2
  • 14
  • My pleasure, and looking forward to your reply. @neha – Liyun Zhang - MSFT Aug 30 '22 at 07:18
  • ```Xamarin.AndroidX.Work.Runtime``` still facing same issue.` if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.O) { NotificationImportance importance = global::Android.App.NotificationImportance.Default; pendingIntent = PendingIntent.GetActivity(mContext, 0, intent, PendingIntentFlags.Immutable); else { pendingIntent = PendingIntent.GetActivity(mContext, 0, intent, PendingIntentFlags.Mutable); }` and installed Work.runtime still same issue – neha Aug 30 '22 at 08:57
  • Sorry for my careless, the package doesn't need in your project. According to the error message, the packages about the firebase caused this error. Did you update these packages to the newest version? @neha – Liyun Zhang - MSFT Aug 30 '22 at 09:06
  • Thanks for advice @Liyun Zhang After update firebase packages now the application working. – neha Sep 01 '22 at 12:31
0

I managed to solve the problem by upgrading my Firebase packages. You might need to update Xamarin.Forms too.

Daniel
  • 9,312
  • 3
  • 48
  • 48