xamarin 形式:强烈考虑使用FLAG_IMMUTABLE,仅当某些功能依赖于可变的PendingIntent时才使用FLAG_MUTABLE

iqjalb3h  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(155)

当我运行应用程序Android OS 11及以下它是工作,但它不工作Android OS 12当我部署应用程序以下运行时异常IM得到.

[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)

请帮忙。

yhqotfr8

yhqotfr81#

首先,您可以进行调试,找出导致此错误的PendingIntent
如果它是您自己创建的,您可以尝试在使用PendingIntent时将标志设置为PendingIntentFlags.ImmutablePendingIntentFlags.UpdateCurrent。有关详细信息,请查看this case
如果它是由您使用的nuget软件包创建的,您可以尝试将软件包的版本升级到最新版本。
另外,我上面提供的案例答案中提到的库,是xamarin中名为Xamarin.AndroidX.Work.Runtime的nuget包,你可以在你的项目中安装最后一个版本。

相关问题