jamesmontemagno / StoreReviewPlugin

Request app store reviews across Xamarin and Windows applications
MIT License
184 stars 24 forks source link

Java.Lang.IllegalArgumentException: Targeting S+ (version 31 and above) #34

Closed simwhi closed 2 years ago

simwhi commented 2 years ago

Bug

Version Number of Plugin: 3.1.0 Device Tested On: Samsung Note 10+ (Android 12) Simulator Tested On: Android 12 emulator

Expected Behavior

Calling: await CrossStoreReview.Current.RequestReview(true); should not result in an exception when running on an Android 12 device/emulator.

Actual Behavior

App crashes with an exception when running on an Android 12 emulator or device.

Java.Lang.IllegalArgumentException: 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.'

Note: App does not crash on an Android 11 emulator. Note: I had a very similar error on app start-up after initially targeting Android 12. I solved this by adding Xamarin.AndroidX.Work.Runtime Nuget package.

Steps to reproduce the Behavior

  1. Tested from Google Play internal testing on an Android 12 device
  2. Tested on Android 12 emulator. Calling: await CrossStoreReview.Current.RequestReview(true); // testing
jamesmontemagno commented 2 years ago

Yeah, this is a weird one as the PlayCore library actually creates the PendingIntent. I have updated to 1.10.2, I have read that fixes it for others. I tested it on my Pixel 4 and it wasn't crashing.

Let me know if NuGet 3.3.0-beta works for you.

simwhi commented 2 years ago

Hi James. Thanks for the really quick response.

I'm not getting an exception error now using 3.3.0-beta on Android 12 devices/emulators.

I also tried 3.3.0-beta through Google internal testing with no issues but I didn't see a review/rating pop-up. I'm calling: await CrossStoreReview.Current.RequestReview(true).

I'll try again on some other devices and accounts.

jamesmontemagno commented 2 years ago

Lovely! YAY! I will push this out to stable once you give it the green light.

saamerm commented 2 years ago

@simwhi why are you passing in true? Shouldn't you be using false?

https://devblogs.microsoft.com/xamarin/android-in-app-reviews/?WT.mc_id=friends-0000-jamont

simwhi commented 2 years ago

@saamerm Hi there.

I was passing in true because I wanted to test the review pop-up.

saamerm commented 2 years ago

@simwhi you won’t be able to see the in app review if you set it to true

simwhi commented 2 years ago

@saamerm I was using internal testing on Google Console to test the in-app review. I thought it would display using this test track.

jamesmontemagno commented 2 years ago

This is the best place for how to test on Android -> https://developer.android.com/guide/playcore/in-app-review/test

Actually sending true wont show the UI at all and just uses the FakeReviewManager. I will document this ;)

simwhi commented 2 years ago

@jamesmontemagno @saamerm Many thanks for all your help.

lhughey commented 2 years ago

Hey @jamesmontemagno. A friendly reminder to update the docs with this info.

I wasn't aware the testMode was being mapped back to the FakeManager class and was using the following logic in my app for testing (which worked for iOS but not for Droid).

#if PROD
await CrossReview.Current.RequestReview(false);
#else
await CrossReview.Current.RequestReview(true);

And of course, LogCat wasn't showing anything, so I went pretty deep trying to debug the issue. If i had only I had tested with a prod build. Doh!

Thanks again.