Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes when targetSdk is 31 #89

Open
prok155 opened this issue Jan 21, 2022 · 10 comments
Open

App crashes when targetSdk is 31 #89

prok155 opened this issue Jan 21, 2022 · 10 comments

Comments

@prok155
Copy link

prok155 commented Jan 21, 2022

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

@marcojak
Copy link
Owner

I was looking at his page: https://groups.google.com/g/google-admob-ads-sdk/c/fmbPnkUCIe8?pli=1
and in particular at this (for native android):

dependencies {
implementation 'com.google.android.gms:play-services-ads:20.4.0'

// For apps targeting Android 12, add WorkManager dependency. 
constraints { 
    implementation('androidx.work:work-runtime:2.7.0') { because '''androidx.work:work-runtime:2.1.0 pulled from play-services-ads has a bug ...'' } 
}

}

It seems that this is a well known problem and the solution they found was to use androidx.work:work-runtime:2.7.0.
I've tried to install the version available for android but that doesn't solve the problem.

@jl-mobitech
Copy link

Following, currently experiencing the same problem when using on API 31

@kelvin526
Copy link

kelvin526 commented Apr 5, 2022

Following, experiencing same issue on my app as will on android 12 device

@jl-mobitech
Copy link

jl-mobitech commented Apr 6, 2022

@prok155 @marcojak @kelvin526 , I managed to fix this while running on Android 12. You just need to install these two packages on your Android project:
image

Can you please verify on your side? Thanks

Update: Xamarin.AndroidX.Work.Runtime 2.7.1.3 won't work. It needs to be only on 2.7.0. I don't know why the latest version won't work.

@prok155
Copy link
Author

prok155 commented Apr 6, 2022

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

@kelvin526
Copy link

kelvin526 commented Apr 7, 2022

@jl-memosoft I can't install those package as my app dev in xamarin form which have compatibility issue.
Anyone else have workaround? TIA

-Update on 9/4/2022-
Found a way to install the Xamarin.AndroidX.Work.Runtime 2.7.0 and now it solved the issue. Thanks!!!

@davidblaine228
Copy link

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

Same here! I was trying to install the latest one (2.7.1.4) and it wasn't installing due to incompatible versions. Your and jl-memesoft advice saved me, thanks!

@gsgou
Copy link

gsgou commented Jul 6, 2022

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

@davidblaine228
Copy link

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

Unfortunately, can't really tell

@BlyZeYT
Copy link

BlyZeYT commented Aug 18, 2022

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

For me, it is required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants