question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App crashes when targetSdk is 31

See original GitHub issue

Describe 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:

  1. Install visual studio 2022
  2. Create new Xamarin project
  3. Install MTAdmob nuget package
  4. Run project on emulator or a phone with Android 12 installed
  5. 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:open
  • Created 2 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
prok155commented, Apr 6, 2022

I’ve installed only Xamarin.AndroidX.Work.Runtime 2.7.0 and it solved issue. @jl-memosoft thank you for solution!

0reactions
BlyZeYTcommented, Aug 18, 2022

@jl-memosoft, @davidblaine228 Is it still required with v1.8.0 update ?

For me, it is required

Read more comments on GitHub >

github_iconTop Results From Across the Web

App starts to crash after upgrade to SDK 31 Android
In your first stack trace it is indicating that the work manager is crashing while trying to create a PendingIntent :
Read more >
Android Question [ SOLVED] Target SDK 31 widget crash
Hello, I am upgrading a widget-enabled app to targetSDK 31. When I install the widget, it does not load and I get an...
Read more >
Migrating from Android API level 30 to 31/32 or App ...
To fix the issue follow the below steps. Step 1: In the File, android > build.gradle, change compiledSdkVersion, targetSdkVersion and ndkVersion ...
Read more >
Media apps targeting 31 crash when interacting with the ...
I have an app that uses a foreground Service with a media notification to play audio. ... It only crashes with the combination...
Read more >
2.1.3 crashes on SDK 31 update #1606
Steps To Reproduce Update app to SDK 31 and get an error. Code To Reproduce /android/build.gradle compileSdkVersion = 31 targetSdkVersion ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found