简体   繁体   中英

XAMARIN.FORMS Android: FLAG_IMMUTABLE needs to be set when targeting Android S+

Ive seen this issue a few times now, but never for xamarin.forms:

When I am trying to deploy on android 12 I am getting:

com.interiorcircle.interiorcircledroid: 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, eg if it needs to be used with inline replies or bubbles.

Here in picture: 在此处输入图像描述

Appearently, a flag needs to be set, but I cannot figure out where.

Anyone has some help here?

Install the Xamarin.AndroidX.work.runtime to remove error. See link below.

See the following https://stackoverflow.com/a/70157415/6902149

In my case following code has fixed the runtime error:

var pendingIntentFlags = (Build.VERSION.SdkInt >= BuildVersionCodes.S)
                ? PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Mutable
                : PendingIntentFlags.UpdateCurrent;
var pendingActivityIntent = PendingIntent.GetActivity(Application.Context, requestCode, activityIntent, pendingIntentFlags);
var pendingIntent = PendingIntent.GetBroadcast(Application.Context, requestCode, intent, pendingIntentFlags);

If you cannot figure out where then you probably don't use PendingIntent in your code.

In that case it means that some of the packages that you use is using this code and they need to fix it. Possibly you need to report the problem to them if they are not already aware of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Firebase Authentication is not working on Android 12, Targeting S+ requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE Android facebook-login library 11.2.0 crashes Android 12 - Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE MediaSessionCompat:Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent In flutter app Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent FacebookAds: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent androidTest: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent Xamarin Forms Targeting version 31 and above requires FLAG_IMMUTABLE App crashes : Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM