App crashes when targetSdk is 31
See original GitHub issueDescribe the bug
App crashes when I set targetSdk to 31 and target framework Android 12. Bug occurs only when I try to run my project on phones and emulators with android 12. Error log:
'com.companyname.mypackagename: 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.'
To Reproduce Steps to reproduce the behavior:
- Install visual studio 2022
- Create new Xamarin project
- Install MTAdmob nuget package
- Run project on emulator or a phone with Android 12 installed
- The app will crash and you will see above error log.
Expected behavior App doesn’t crash on devices with Android 12
Smartphone (please complete the following information):
- google pixel 4 xl
- android 12
Additional context Here are changes to pending intents when app is targeting Android12. https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (1 by maintainers)
Top GitHub Comments
I’ve installed only
Xamarin.AndroidX.Work.Runtime 2.7.0
and it solved issue. @jl-memosoft thank you for solution!For me, it is required