jamesmontemagno / StoreReviewPlugin

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

Google Play In-App Review Feature Request #6

Closed skyapps-co closed 3 years ago

skyapps-co commented 4 years ago

Feature Request:

Are there any plans to update the package to include the In App Review feature for Android? Currently the RequestReview() method works for iOS but not Android, and it appears that Google now has an API for it. Thank you!

https://developer.android.com/guide/playcore/in-app-review https://developer.android.com/guide/playcore/in-app-review/kotlin-java#java

jamesmontemagno commented 4 years ago

Fancy! Will look for sure :)

darrabam commented 3 years ago

@jamesmontemagno please add it!

jamesmontemagno commented 3 years ago

https://github.com/jamesmontemagno/StoreReviewPlugin/pull/7

saamerm commented 3 years ago

@skyapps-co @darrabam the v3.0 beta has this feature. It was released 30 minutes ago

darrabam commented 3 years ago

@saamerm Thanks! I did try it on a simple black project, but nothing happens. Works fine with iOS. using the latest XF: 4.8, Essentials:1.5.3.2, StoreReview: v3-beta

Note that I'm getting the following message in the output window: 09-24 09:37:37.442 I/PlayCore(21922): UID: [10107] PID: [21922] ReviewService : requestInAppReview (MY_APP_NAME) 09-24 09:37:37.495 I/PlayCore(21922): UID: [10107] PID: [21922] ReviewService : Initiate binding to the service. 09-24 09:37:37.496 I/PlayCore(21922): UID: [10107] PID: [21922] ReviewService : Failed to bind to the service.

image

ezgif com-optimize (1)

saamerm commented 3 years ago

@darrabam you can only see the UI if you have downloaded the app from the Google Play store. The easiest way is to upload it onto "Internal App Sharing"

RadoslawKubas commented 3 years ago

Hello! I tried this feature just now, without success. As expected on simulator there is an error message mentioned above, but when I try in beta app on the real device (installed from Play Store alpha distribution) the popup window dans't appear (but there is no error message in logs as well).

UPDATE: After awaiting method I noticed there is exception:

Java.Lang.NoSuchMethodError: no non-static method "Lcom/google/android/play/core/review/c;.requestReviewFlow()Lcom/google/android/play/core/tasks/Task;"

saamerm commented 3 years ago

@RadoslawKubas did you do ‘RequestReview(false)’ or did you set it to true?

RadoslawKubas commented 3 years ago

@saamerm I tested both in case, when is true, just as expected nothing happened (no exception). When is false, I got exception. One maybe important info, I'm using Link All and profiled AOT with custom AOT profile.

saamerm commented 3 years ago

The linker is likely the issue, as you can see it says that it’s not able to find the function. @RadoslawKubas

RadoslawKubas commented 3 years ago

@saamerm I tried just now without linker (or exactly Sdk Only) and same exception. Build configuration is

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2020-09-27T17:02:23.8197740Z     <DefineConstants>ANDROID;</DefineConstants>
2020-09-27T17:02:23.8198070Z     <DebugSymbols>false</DebugSymbols>
2020-09-27T17:02:23.8198420Z     <DebugType>portable</DebugType>
2020-09-27T17:02:23.8198740Z     <Optimize>true</Optimize>
2020-09-27T17:02:23.8199040Z     <OutputPath>bin\Release</OutputPath>
2020-09-27T17:02:23.8199320Z     <ErrorReport>prompt</ErrorReport>
2020-09-27T17:02:23.8199630Z     <WarningLevel>4</WarningLevel>
2020-09-27T17:02:23.8199960Z     <AndroidManagedSymbols>true</AndroidManagedSymbols>
2020-09-27T17:02:23.8200320Z     <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
2020-09-27T17:02:23.8200700Z     <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
2020-09-27T17:02:23.8201470Z     <AndroidSupportedAbis>armeabi-v7a;arm64-v8a</AndroidSupportedAbis>
2020-09-27T17:02:23.8201930Z     <AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
2020-09-27T17:02:23.8202310Z     <AndroidUseAapt2>true</AndroidUseAapt2>
2020-09-27T17:02:23.8202610Z     <BundleAssemblies>False</BundleAssemblies>
2020-09-27T17:02:23.8202980Z     <AndroidEnableMultiDex>false</AndroidEnableMultiDex>
2020-09-27T17:02:23.8203330Z     <AndroidDexTool>d8</AndroidDexTool>
2020-09-27T17:02:23.8203630Z     <AndroidLinkMode>SdkOnly</AndroidLinkMode>
2020-09-27T17:02:23.8204020Z     <AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
2020-09-27T17:02:23.8204350Z     <AotAssemblies>False</AotAssemblies>
2020-09-27T17:02:23.8205150Z     <AndroidAotAdditionalArguments>no-write-symbols,nodebug</AndroidAotAdditionalArguments>
2020-09-27T17:02:23.8205590Z     <EnableLLVM>False</EnableLLVM>
2020-09-27T17:02:23.8205900Z     <AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
2020-09-27T17:02:23.8206310Z     <AndroidUseDefaultAotProfile>false</AndroidUseDefaultAotProfile>
2020-09-27T17:02:23.8206650Z     <MandroidI18n />
2020-09-27T17:02:23.8206960Z     <AndroidEnablePreloadAssemblies>True</AndroidEnablePreloadAssemblies>
2020-09-27T17:02:23.8207310Z     <AndroidLinkTool>r8</AndroidLinkTool>
2020-09-27T17:02:23.8207620Z     <AndroidPackageFormat>aab</AndroidPackageFormat>
2020-09-27T17:02:23.8207940Z   </PropertyGroup>
saamerm commented 3 years ago

@RadoslawKubas In App Review on Android is supported on Android 5.0 (API level 21) or higher that have the Google Play Store installed.

If that's not the issue then if you switch the Linker Behavior to None and Code Shrinker (AndroidLinkTool) to none, it should fix any issues you are seeing.

That's probably not the best solution due to app sizes, so I did some research, trial & error, and you should be able to still use r8, d8 and Link All if you add these to a proguard.cfg file set to the proguard build config:

-keep class com.google.android.play.core.review.** { *; }
-keep class com.google.android.play.core.tasks.** { *; }
jamesmontemagno commented 3 years ago

I will add an API check for API 21+ and then document that for proguard as well :)

sgjesse commented 3 years ago

An error like

Java.Lang.NoSuchMethodError: no non-static method "Lcom/google/android/play/core/review/c;.requestReviewFlow()Lcom/google/android/play/core/tasks/Task;"

after shrinking an app with R8 is typically caused by the missing keep rules for reflection used by the app. If the keep rules cited in https://github.com/jamesmontemagno/StoreReviewPlugin/issues/6#issuecomment-699691779 fixes the issue it would be worthwhile to look closer into the generated code to see the concrete reflection being used to limit the scope of the keep rules and keep the app smaller. Could it be that some reflection is used when compiling await from C# to android code?

(for the record, I work on the R8 team)

RadoslawKubas commented 3 years ago

Thanks for all advices. It takes more time to see if it really works due to an unexpected long publication time on the Play Store. I had to wait a few days to see the application in the internal channel. Anyway, it helped to resolve the first exception, but now I'm seeing a new exception:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appwithkiss.tipcalculator/com.google.android.play.core.common.PlayCoreDialogWrapperActivity}: java.lang.InstantiationException: java.lang.Class<com.google.android.play.core.common.PlayCoreDialogWrapperActivity> cannot be instantiated
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3228)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3443)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:221)
at android.app.ActivityThread.main(ActivityThread.java:7520)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.InstantiationException: java.lang.Class<com.google.android.play.core.common.PlayCoreDialogWrapperActivity> cannot be instantiated
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at androidx.core.app.CoreComponentFactory.instantiateActivity(Unknown Source:0)
at android.app.Instrumentation.newActivity(Instrumentation.java:1251)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3216)
RadoslawKubas commented 3 years ago

Adding one more rule

-keep class com.google.android.play.core.common.PlayCoreDialogWrapperActivity

solved the problem, everything seems to be fine now.

saamerm commented 3 years ago

@RadoslawKubas ah thank you! I was trying to figure that one out. We are trying to fix the play core bindings library, so that this nuget works without these issues!!

CDrosos commented 3 years ago

Hello, im using linking sdk only without code shrinker, the app is published on Google play in public but i dont see anything when i run this code:

public bool OnNavigationItemSelected(IMenuItem item)
{
    if (id == Resource.Id.Nav_Rate)
    {
     var task = Task.Run(() => RequestReview());
     task.GetAwaiter().GetResult();
    }
}
...
private static void RequestReview()
{
    MainThread.BeginInvokeOnMainThread(async () =>
    {
          await CrossStoreReview.Current.RequestReview(false).ConfigureAwait(false);
          Preferences.Set(Settings.ReviewClickedOrIgnoredKey, true);
    });
}

while debugging i only get the ReviewService : Failed to bind to the service. output message

saamerm commented 3 years ago

@CDrosos have tried just using: CrossStoreReview.Current.RequestReview(false); without the await-async?

CDrosos commented 3 years ago

im publishing now with that and letting you know the results, thank you

CDrosos commented 3 years ago

@saamerm i have just tried and nothing happens when i run the code: CrossStoreReview.Current.RequestReview(false) ; Why we dont get any exceptions or something like that?

Should i try again with code shrinker in r8? maybe the linking sdk assemblies is the cause, should i skip linking any assemplie?

saamerm commented 3 years ago

I appreciate your patience 😄

CDrosos commented 3 years ago

@saamerm ok i have create this issue

InquisitorJax commented 3 years ago

... is there an eta when this will make it out of beta?