MTAdmob icon indicating copy to clipboard operation
MTAdmob copied to clipboard

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE

Open douglassimaodev opened this issue 2 years ago • 1 comments

I installed the latest version and I am getting the following error:

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.

douglassimaodev avatar Jun 16 '22 21:06 douglassimaodev

Ok so I am not sure what this will impact when publishing and installed in android 12+ but if you right click android project and go to Properties and change Application -> Compile using android version: from 12+ to 11.0 (R) and in Android Manifest -> Target Android version from 12+ to 11.0 (api Level 30 - R) error is sorted

douglassimaodev avatar Jun 17 '22 10:06 douglassimaodev

These steps worked for me. I used BroadcastReceiver and PendingIntent in my project so I changed them to

[BroadcastReceiver(Enabled = true, Label = "Local Notifications Broadcast Receiver", Exported = true)] for pending intent

var pendingIntentFlags = (Build.VERSION.SdkInt >= BuildVersionCodes.S)
                ? PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Mutable
                : PendingIntentFlags.UpdateCurrent;
var pendingIntent = PendingIntent.GetBroadcast(AndroidApp.Context, code, intent, pendingIntentFlags);

and finally installed Xamarin.AndroidX.Work.Runtime 2.7.0

arahmancsd avatar Oct 15 '22 22:10 arahmancsd

As @arahmancsd said, the trick is to update Xamarin.AndroidX.Work.Runtime to 2.7.0.

I'm going to update the sample project to show that. For now I'll close the issue but feel free to re-open it if needed

marcojak avatar Oct 27 '22 17:10 marcojak

These steps worked for me. I used BroadcastReceiver and PendingIntent in my project so I changed them to

[BroadcastReceiver(Enabled = true, Label = "Local Notifications Broadcast Receiver", Exported = true)] for pending intent

var pendingIntentFlags = (Build.VERSION.SdkInt >= BuildVersionCodes.S)
                ? PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Mutable
                : PendingIntentFlags.UpdateCurrent;
var pendingIntent = PendingIntent.GetBroadcast(AndroidApp.Context, code, intent, pendingIntentFlags);

and finally installed Xamarin.AndroidX.Work.Runtime 2.7.0

can you please explain for a newbie how and where to do it exactly?

N1koV373z avatar Jan 11 '23 08:01 N1koV373z

These steps worked for me. I used BroadcastReceiver and PendingIntent in my project so I changed them to [BroadcastReceiver(Enabled = true, Label = "Local Notifications Broadcast Receiver", Exported = true)] for pending intent

var pendingIntentFlags = (Build.VERSION.SdkInt >= BuildVersionCodes.S)
                ? PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Mutable
                : PendingIntentFlags.UpdateCurrent;
var pendingIntent = PendingIntent.GetBroadcast(AndroidApp.Context, code, intent, pendingIntentFlags);

and finally installed Xamarin.AndroidX.Work.Runtime 2.7.0

can you please explain for a newbie how and where to do it exactly?

You can do this in your Platform project (Android) where you have used PendingIntentsFlags.

arahmancsd avatar Jan 11 '23 08:01 arahmancsd