On trying to migrate Google billing integration from version 4 to 5, I'm getting an error 'Client does not support ProductDetails' on calling queryProductDetailsAsync.
List<QueryProductDetailsParams.Product> productList = List.of(QueryProductDetailsParams.Product.newBuilder()
.setProductId("ppgapp1")
.setProductType(BillingClient.ProductType.SUBS)
.build());
QueryProductDetailsParams params = QueryProductDetailsParams.newBuilder()
.setProductList(productList)
.build();
billingClient.queryProductDetailsAsync(params, listener);
Are there any changes needed to be made on the console on migration?
And how long it'll take to complete review on submitting to closed or internal test track for Google billing integration?
I face same issue when my emulator PlayStore application version is too old (in my case it is 23.0.21...)
Update PlayStore application to newer version will solve the problem (30.9.0...)
Here is how to update the Play Store app
If you want to guide user to update the PlayStore app, you can do like
billingClient.queryProductDetailsAsync(productParams) { billingResult, productDetails ->
if (billingResult.responseCode == BillingClient.BillingResponseCode.FEATURE_NOT_SUPPORTED) {
Log.e("TAG", "Feature not supported ")
runOnUiThread {
Toast.makeText(this#MainActivity, "Please update PlayStore app", Toast.LENGTH_LONG).show()
// or AlertDialog or any error message
}
return#queryProductDetailsAsync
}
...
}
I had experienced the same problem. I couldn't find any information on why the problem is occurring. You can use it after checking whether the ProductDetail feature is supported.
BillingResult billingResult = billingClient.isFeatureSupported( BillingClient.FeatureType.PRODUCT_DETAILS );
if ( billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK ) {
// use billingClient.queryProductDetailsAsync()
}
Getting this error when I use google play version 21.2.12-21. When I use the 31.2.29-21 version of google play on another device, the item can be successfully queried. I can't use the 5.0 version of the billing library because it affects the user's payment
Issue resolved
Issue was occuring on one device and not occuring on another device with latest library.
Upon debuging I used old library on device where issue was occuring. And it was working fine on old library.
So after alot of trouble shoot I do following to resolve issue on that device with latest library code.
On device where issue is occurred
Do following
Update device OS update if there is any. In my case there was security patch update. Notification was there to update.
update play store if already not updated
Then clear data storage of play store app under setting of play store app. Then force stop play store app and then open play store app
uninstall and reinstall the android app again
After that my app shows product details as well as purchase pop up with latest billing library.
Thank you
I had to reinstall the app for the Billing client to recognize the supported product ID. I imagine that simply purged some stale cache behind the scenes.
I'm trying to utilize the Review API (Play Core library 1.8.0) from Google which was just released yesterday.
See https://developer.android.com/guide/playcore/in-app-review
I followed the troubleshooting section carefully, I made sure the app is downloaded from the internal testing track, my account does not have a review on the app, the app is in the library of that user etc.. I even tried with a completely new account, but every time the com.google.android.finsky.inappreviewdialog.InAppReviewActivity is shown only to immediately disappear.
I'm calling the following code from the onResume() method of my activity:
reviewManager = ReviewManagerFactory.create(AlarmClock.this);
Logger.logInfo("Rating: requestReviewFlow() ");
reviewManager.requestReviewFlow().addOnSuccessListener(new OnSuccessListener<ReviewInfo>() {
#Override
public void onSuccess(ReviewInfo result) {
Logger.logInfo("Rating: launchReviewFlow() ");
reviewManager.launchReviewFlow(AlarmClock.this, result).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void result) {
Logger.logInfo("Rating: launchReviewFlow() success ");
}
});
}
});
Both listeners return success.
Here is the log output:
2020-08-06 16:01:29.317 29618-29618/? I/MyApp: [06Aug 16:01:29.317, main]: Rating: requestReviewFlow()
2020-08-06 16:01:29.318 29618-29618/? I/PlayCore: UID: [10409] PID: [29618] ReviewService : requestInAppReview (com.mypackage)
2020-08-06 16:01:29.320 29618-29774/? I/PlayCore: UID: [10409] PID: [29618] ReviewService : Initiate binding to the service.
2020-08-06 16:01:30.081 29618-29618/? I/PlayCore: UID: [10409] PID: [29618] ReviewService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.inappreviewservice.InAppReviewService})
***2020-08-06 16:01:30.082 29618-29774/? I/PlayCore: UID: [10409] PID: [29618] ReviewService : linkToDeath***
2020-08-06 16:01:30.355 29618-29637/? I/PlayCore: UID: [10409] PID: [29618] OnRequestInstallCallback : onGetLaunchReviewFlowInfo
2020-08-06 16:01:30.355 29618-29774/? I/PlayCore: UID: [10409] PID: [29618] ReviewService : Unbind from service.
2020-08-06 17:02:21.590 7478-7478/? I/MyApp: [06Aug 17:02:21.590, main]: Rating: launchReviewFlow()
2020-08-06 17:02:21.630 1511-4316/? I/ActivityTaskManager: START u0 {cmp=com.android.vending/com.google.android.finsky.inappreviewdialog.InAppReviewActivity (has extras)} from uid 10122
2020-08-06 17:02:21.750 7478-7478/? I/MyApp: [06Aug 17:02:21.750, main]: Rating: launchReviewFlow() success
Anyone had success to make this working? Any tips. Big thanks!
Okay, I had exactly the same problem as described by the OP and as is listed on the issue tracker here: https://issuetracker.google.com/issues/167352813 and has still not been resolved as yet by GoogleDev.
Same UI manifestation(s), same log entries (incidentally, the log entries are the same when it works though, complete with the entry that says “ReviewService : linkToDeath”, but let’s not worry about that eh?)
The key thing, you'll no-doubt want to know though, to avoid too much suspense, is that IT WORKS. The in-app review API works! No need for me to repeat the block of code for calling the review flow, it is pretty much exactly the same as in the docs, similar to what the OP has listed, and several others have kindly repeated.
Took me a while, but I got to the bottom of it as follows, in a nutshell:
Your device needs to have the latest Google Play system update
Irrespective of whether your app is published on the Play Store YOU ABSOLUTELY NEED TO DO YOUR TESTING VIA INTERNAL APP TESTING or SHARING (I only did “Internal App Testing”, but I expect the same applies)
To debug your code with Android Studio, you need to have installed your Internal App Testing version on your device AND RUN THE DEBUGGER SUCCESSFULLY WITH YOUR IAT VERSION STILL INSTALLED ON THE DEVICE AT LEAST ONCE
Once you are up and running, when the review dialog pops up, you have to note that, if you submit a review, then you have utilised all your quota. When you try and launch the review flow again it looks like the “problem” has returned. You get “successful” launch but nothing shows. If you have submitted a review (and this is why it absolutely needs to be in IAT), then it is only a “private review” (not seen publicly on your app page), and you need to DELETE THE REVIEW TO GET THE POP UP TO SHOW AGAIN.
You can select “Not Now” instead of "Submit" ad infinitum (well, I tried about two-dozen times) and the pop-up dialog will launch each time you (re)call the flow.
So, step-by-step fix:
Prepare your device by uninstalling your app, then ensure you have the latest Google Play Store update. On my Sony Xperia X1 this is Settings->About Phone->Android version->Google Play system update.
Irrespective of whether the above restarted your device, turn your device off and then back on again (don’t restart - off then on i.e. cold boot).
Now go into Settings->Apps & notifications->Google Play->Storage & Cache, then do both CLEAR CACHE and CLEAR STORAGE. (This should not affect any of your installed apps).
Create a signed release for IAT based on your In-App review code base. You have to do this even if you have a release in production.
Now install your IAT RELEASE on your device - the words, "(Internal Beta)" or words to that effect, should be appended to your app name if you are downloading from the right location (i.e. IAT), (do not run it, just install)
In Android studio Clean, Rebuild and Debug, your app on the device with the IAT version installed. If you get a message saying "The device already has an application with the same package but a different signature." DON'T CLICK OK TO UNINSTALL YOUR IAT VERSION Follow the instructions here: Android: Error - App has same packaged different signature. The accepted answer is the correct one. If you have to do this, please note you should do a Clean and Rebuild->Debug again.
Hopefully, now all should be okay. Once you have done the above steps successfully, you can actually "clean" uninstall the app from the device on subsequent debugging sessions, and it will still work.
To test, and to delete a review note the following. When you submit a review, you will be able to see it in Google Play Console (not under "Reviews", incidentally but) under "Testing Feedback". Also you cannot delete your review under "Testing Feedback" it seems. You need to delete it from your IAT download page on the device. On there, under the heading Your private feedback, select the right-angled ellipsis thingy to the right of your review and simply "Delete".
Your pop-up will now show every time until you submit another review. Voila!
I have raised a issue on google issue tracker regarding this. I also have the same issue.
For more info check this my issue tracking url: https://issuetracker.google.com/issues/167352813
I also saw the same problem, my request review flow works, then the launch review flow works, but nothing displays (I do notice the small line at the center of the bottom of the screen appears briefly, and my audio cuts out briefly as the app is paused and then resumed but no review flow appeared).
I was able to get it to work by adding a user to my device that was not in my list of License Testers (Google developer console) and had not reviewed my app previously. I was able to display the rating popup once, I cancelled the operation so that I could test it again, but it would not reappear afterwards. It appears to be a one shot thing and they are aggressively guarding against annoying the user with review popups.
This feature doesn't seem useful for my case, I have a button on the settings screen to rate my app. Since I have no way of knowing what happened, I can't thank the user, I can't disable the button or display an "you already rated this thank you" message, and the button just appears to do nothing so it looks like a bug. I guess the intended use is to ask the user during gameplay, and if they cancel the dialog accidentally then it's just too bad for you.
Ideally Google should allow License Testing users to display this popup more than once for testing purposes.
I just want to share the code that is working reliably today (2020-09-03). It was essentially copied from the official document
ReviewManager manager = ReviewManagerFactory.create(activity);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
try {
if (task.isSuccessful()) {
// We can get the ReviewInfo object
ReviewInfo reviewInfo = task.getResult();
Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
flow.addOnCompleteListener(task2 -> {
// The flow has finished. The API does not indicate whether the user
// reviewed or not, or even whether the review dialog was shown. Thus, no
// matter the result, we continue our app flow.
utility.logMessageAsync(activity, "In-app review returned.");
});
} else {
// There was some problem, continue regardless of the result.
goToAppPage(activity);
}
} catch (Exception ex) {
utility.logExceptionAsync(activity, "Exception from openReview():", ex);
}
});
It was tested with internal app sharing on a Android 10. It never failed to show the review dialog.
I had the same problem and I solved with the next steps:
Adding my APK file to internal testing channel
Adding a tester user with a gmail account ex: email#gmail.com. GSuite mails don't work
With the tester mail, accept the tester privilege
With a physical device signed with the tester user email, go to Play Store and download the app
It works!!
Note: If App is not published yet, you could use Google Console App Sharing
Try uploading your app to Internal App Sharing
I have found that with the exact same apk uploaded to Internal Testing versus Internal App Sharing, the latter is more reliable in displaying the In-App Review Flow every time I try testing it.
You would need to enable Internal app sharing in the Play Store to be able to install your app from the link provided by uploading your apk.
Basically go to the Play Store, go to Settings, scroll down to Play Store version and tap it a bunch of times to "Become a developer", then enable Internal app sharing.
For all the users that needs a working JAVA code, please find my code below:
ReviewInfo reviewInfo;
ReviewManager manager;
OnCreate
manager = ReviewManagerFactory.create(this);
private void Review(){
manager.requestReviewFlow().addOnCompleteListener(new OnCompleteListener<ReviewInfo>() {
#Override
public void onComplete(#NonNull Task<ReviewInfo> task) {
if(task.isSuccessful()){
reviewInfo = task.getResult();
manager.launchReviewFlow(MainActivity.this, reviewInfo).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(Exception e) {
Toast.makeText(MainActivity.this, "Rating Failed", Toast.LENGTH_SHORT).show();
}
}).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(MainActivity.this, "Review Completed, Thank You!", Toast.LENGTH_SHORT).show();
}
});
}
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(Exception e) {
Toast.makeText(MainActivity.this, "In-App Request Failed", Toast.LENGTH_SHORT).show();
}
});
}
Make sure the below is implemented:
implementation 'com.google.android.play:core:1.8.0'
And please also note, that the dialog will only display if your app is in production, alpha or internal testing on the Google Play Console Account.
I had same issue, I've followed below steps then working fine
If you mark stars and submit, then need to remove your review from
play store.
Clear data for Play Store.
My working code:
private fun askForReview() {
val manager = ReviewManagerFactory.create(this)
manager.requestReviewFlow().addOnCompleteListener { request ->
if (request.isSuccessful) {
val reviewInfo = request.result
manager.launchReviewFlow(this, reviewInfo).addOnFailureListener {
logWarning("In-app review request failed, reason=$it")
}.addOnCompleteListener { _ ->
logInfo("In-app review finished")
}
} else {
logWarning("In-app review request failed, reason=${request.exception}")
}
}
}
Tested on an app from Internal Test track (there is no quota there).
The documentation says
To provide a great user experience, Google Play enforces a quota on
how often a user can be shown the review dialog. Because of this,
calling a launchReviewFlow method might not always display a dialog.
For example, you should not have a call-to-action option (such as a
button) to trigger a review as a user might have already hit their
quota and the flow won’t be shown, presenting a broken experience to
the user.
So you don't expect it to show the dialog every time and also there's no way to know if the dialog is shown or not nor the user has reviewed your app or not either
I had exactly the same problem, the dialog never appeared to me ...
But even so, I left it implemented in the application and posted it on the Play store.
Then I downloaded and tested the version and everything works perfectly.
Most of the cases are covered in other answers. I want to highlight few more troubleshooting Steps .
Make sure the user account is not protected (like some enterprise accounts) use some personnel G mail ID to test.
Make Sure the version of beta app is greater then the currently Live application
if its not then it will not show up the review dialogue.
In MY case, yes, this will not work if the account that’s being used already left a review.
HOWEVER, deleting the review from the Play Store doesn’t always work. Something lingers.
So, unless you want to be sad, CLEAR THE PLAY STORE APP’S STORAGE EVERY TIME YOU DELETE THE REVIEW THAT’S LEFT. You do not need to also clear the cache as well as others have suggested (clearing the storage will also do this), but clearing the Play Store app’s cache was not enough. Once I did this, I could consistently test this ad nauseum.
Good luck. What a mess this is.
Documentation says that it won't be shown every time you request it since it has quota restrictions:
https://developer.android.com/guide/playcore/in-app-review#quotas
I just included it in my project and it showed the dialog only one time. It is a little inconvenient since we don't have any controls over it.
Also, I noticed that if you try to show the dialog again and again, navigation bar starts blinking (like it wants to show the dialog but it gets dismissed).
My problem was solved by typecasting the context and activity to the required form i.e application context and activity . Although it seems illogical, nothing else worked for me
I joined the beta in the store and it showed. But just show once time.
Just to be clear you are not using com.mypackage right?
2020-08-06 16:01:29.318 29618-29618/? I/PlayCore: UID: [10409] PID: [29618] ReviewService : requestInAppReview (com.mypackage)
Ensure that the appId used is the one that it's "owned" (aka installed by) by the selected account in the Play Store in the device.
I believe the test guide (https://developer.android.com/guide/playcore/in-app-review/test) is clear in terms of how to test it given the different requirements.
My tips:
Use only one account in the device
Ensure that account has installed the app (appears in the app & games > Library section in Play Store)
The account is a GMAIL one, not a GSuit
You can review with the account if you go to the app play listing page.
The account has not reviewed
If you intend to use the Internal Test Track ensure the account has joined the test track.
When switching between different accounts and testing things out, sometimes might be helpful to "Clear Data" from the Play Store app.
Try all the above with different account
PS: You could test also the Internal App Sharing.
Just discovered that the app must be approved from google (i.e. not having the temporary name)
The code is correct no issue
we can follow a few steps
app upload following URL https://play.google.com/console/u/0/internal-app-sharing/
setup google play console your project setup->inter app sharing-> anyone can download select the option -> to save
3 check your mobile internal app sharing to play store app
I know this is an old thread but none of the steps for the solutions provided worked for me. They are all great advice and should be followed. However, if you also can't get the in-app review UI to pop up, you might want to try what I did. (I'm sure there is probably a key step in there that is the actual solution so all these steps may not be necessary.)
Ultimately, the issue was that I initially installed my app using a gmail suite email (same one I used to deploy the app if that makes a difference) and the app remained associated with that user even after switching to other users on my phone.
Bad user is active in Google Play app
Uninstall the app (duh)
Go to bad user's library and remove the app
Stop and delete data/cache for Play Store app
(At this point I removed/re-added my good gmail user account in android settings but probably not necessary)
Start and switch to good gmail account in Play Store app
(If you search for the app, you should see a little note under the name saying the app is associated with the bad user account. This means it will not work right. Don't install it yet!)
This is the important part!
Start Chrome browser, and login with good gmail account
Go to email and CLICK ON THE LINK TO INSTALL THE APP FROM YOUR INVITE to test it (notice that was in all caps so must be important)
The app should now be associated on this device with the good account and you should see the in-app review pop-up UI
For anyone still having this problem:
I used applicationContext and now it is working and displaying just fine.
For some reason, the context and activity don't work, only applicationContext.
Please test using FakeReviewManager :)
ReviewManager manager = new FakeReviewManager(context);
https://developer.android.com/guide/playcore/in-app-review/test
I have an app with a subscription in Google Play.
When the user starts the app, I need to know if the user has an active subscription. This would seem an obvious thing to do, but from searching and trying to implement it, it seems impossible?
I am using Google's newer billing 2/3, following Google's tutorials,
class BillingManager implements PurchasesUpdatedListener
...
public void checkAsync() {
Log.e(TAG, "checkAsync");
billingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.SUBS, new PurchaseHistoryResponseListener() {
#Override
public void onPurchaseHistoryResponse(BillingResult billingResult, List<PurchaseHistoryRecord> list) {
Log.e(TAG, "checkCached result: " + list);
if (list == null) {
return;
}
for (PurchaseHistoryRecord ps : list) {
//System.out.println("PAYMENT: " + ps.getSku() + " : " + ps.getPurchaseTime());
}
}
});
}
public void checkCached() {
Log.e(TAG, "checkCached");
List<Purchase> result = billingClient.queryPurchases(BillingClient.SkuType.SUBS).getPurchasesList();
Log.e(TAG, "checkCached result: " + result);
if (result == null) {
return;
}
for (Purchase purchase : result) {
handlePurchase(purchase);
}
}
This is how I think you're supposed to get a user's purchases. But it does not work at all, both calls return null always. It only returns the correct purchases when you reinstall the app or clear the data.
So how exactly is an app supposed to do this?
Purchasing works for the app once I enter internal testing, and download it through the Google Play link. (before that subscriptions do not work at all).
*** updated
So to further clarify:
I am using a valid test user, and subscriptions are working correctly. My question is on the what the API queryPurchases() or queryPurchaseHistoryAsync() are suppose to do.
What I am seeing, is that these only return purchases that have not be processed by the app. They seem to store that the purchase was processed in the apps data.
After the purchase these return null, after the app restarts these return null.
If I clear the app datam or reinstall the app then they return the purchase (once), then again null after restart.
From what I see, these are only useful to detect when a user reinstalls your app, or installs on a different phone. They cannot be used to determine the status of a subscription.
So my question is,
1 - is this something that just does not work in internal testing and will magically work differently when the app is release?
2 - is there a different API that your suppose to use to check the status of a subscription?
3 - are you suppose to manage subscriptions yourself in your app by storing a user preference/cookie when you acknowledge the subscription the first time so you know when the subscription expires?
You need "licenced testers". They would allow you to "sideload" your app on devices, even for debug builds. My interpretation of sideload in this case would cover installing from Android Studio build tools as well as adb install .... and other methods that don't involve the play store.
https://developer.android.com/google/play/billing/test
Ordinarily, the Google Play Billing API is blocked for apps that aren't signed and uploaded to Google Play. License testers can bypass this check, meaning you can sideload apps for testing, even for apps using debug builds with debug signatures without the need to upload to the new version of your app. Note that the package name must match that of the app that is configured for Google Play, and the Google account must be a license tester for the Google Play Console account.
I also don't see how you're using startConnection. Until that's completed successfully I wouldn't be sure you have the latest data. I wouldn't be surprised if that makes you get stale values. I would check that carefully to make sure there's no silent errors happening, by both looking at onBillingSetupFinished and onBillingServiceDisconnected. And for the time being avoid trusting queryPurchases():
https://medium.com/#NandagopalR/integrating-google-play-billing-into-an-android-application-b6eb6af176a7
The queryPurchases() method uses a cache of the Google Play Store app without initiating a network request. If you need to check the most recent purchase made by the user for each product ID, you can use queryPurchaseHistoryAsync(), passing the purchase type and a PurchaseHistoryResponseListener to handle the query result.
By the way what's the value of isReady() right before queryPurchaseHistoryAsync, and what's the value of BillingResult::getDebugMessage and BillingResult::getResponseCode?
Also, use isFeatureSupported, though it seems it's not like your problem is coming from here. But I'd advise not testing with subscriptions until you get all the moving parts working: https://developer.android.com/reference/com/android/billingclient/api/BillingClient#isFeatureSupported(java.lang.String)
Okay, figured it out, was my mistake.
I was calling queryPurchases() in my main activity onCreate(), but the BillingClient was not ready yet.
I moved it to onBillingSetupFinished() and it now returns the correct purchases.
Everything is now working as expected. You get the active subscriptions when you call queryPurchases() after an app restart.
Implemented in-app update feature, using the following code snippet:
private void showInAppUpdateDialog(boolean isMandatoryUpdate) {
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
|| appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
int appUpdateType = isMandatoryUpdate ? IMMEDIATE : AppUpdateType.FLEXIBLE;
int requestCode = isMandatoryUpdate ? REQUEST_APP_UPDATE_IMMEDIATE : REQUEST_APP_UPDATE_FLEXIBLE;
if (appUpdateInfo.isUpdateTypeAllowed(appUpdateType)) {
// start the app update
try {
appUpdateManager.startUpdateFlowForResult(appUpdateInfo, appUpdateType, targetActivity, requestCode);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
}
}).addOnFailureListener(e -> {
e.printStackTrace();
});
}
I am testing in-app update on the device which has Android 9. Still, it is giving me following an error (ERROR_API_NOT_AVAILABLE):
com.google.android.play.core.install.InstallException: Install Error(-3): The API is not available on this device. (https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_API_NOT_AVAILABLE)
at com.google.android.play.core.appupdate.i.a(Unknown Source:24)
at com.google.android.play.core.internal.o.a(Unknown Source:13)
at com.google.android.play.core.internal.j.onTransact(Unknown Source:22)
at android.os.Binder.execTransact(Binder.java:731)
It is saying that check the following link:
https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_API_NOT_AVAILABLE)
Using Play core library version: 1.6.5
Latest core library version:
implementation 'com.google.android.play:core:1.7.0'
However, I am not able to get why it is saying that ERROR_API_NOT_AVAILABLE. Any help would be appreciated!
Firstly, please check that you are using the latest version of the play library.
Secondly, understated fact: Please check the app you are testing has the same package name which is available on the play store.
Example:
You have an app on the play store with package name com.example.app but you are testing your app with package name com.example.app.debug. You will get this error: ERROR_API_NOT_AVAILABLE
Note: You need to have at least one version of your app on the play store when you are testing.
On top of what Vipal suggested, the issue may be due to a signature mismatch between the version you have installed on the device and the one that Play Store would deliver (this is a common issue if you try to test it with debug builds). See https://developer.android.com/guide/playcore/in-app-updates#troubleshoot
Recently the Play Core API started returning an API_NOT_AVAILABLE error if the app is not owned by the user or the signatures mismatch, while before it used to return a successful UPDATE_NOT_AVAILABLE Task.
The recommendation is:
if you use the Kotlin Extension, make sure that you are catching the exception thrown by requestAppUpdateInfo
if you use PlayCore Java, make sure you have an onFailureListener that handles failures from getAppUpdateInfo
in order to test a debug build, you can use Internal App Sharing, as explained here: https://developer.android.com/guide/playcore/in-app-updates#internal-app-sharing
Source: I work on the Play Core team
My app was working fine before today, but I started getting this error today. One temporary workaround is to clear your Google Play Store cache and storage and then try launching the app. For me, it works only the first time, but fails afterwards. Before launching the app again, I have to clear the cache and storage again. I think there is something wrong on Google Play Store side due to which this issue is happening because everything was fine for me before today.
Got the same error, tried all solutions described here, nothing works.
App installed from Play Store Internal Test track with Version Code 267, then submitted new update to the same track with Version Code 268.
Play Store shows available update but the application still says ERROR_API_NOT_AVAILABLE
Clear Play Store data and cache does not help.
Description of ERROR_API_NOT_AVAILABLE say that it means “API is not available on device”
After carefully reading again this page, I have noticed that “in-app updates support apps running on only Android mobile devices and tablets, and Chrome OS devices”
Android TV not mentioned, I think it’s the reason in my case.
Temporary workaround for the moment is to surround the OnCompleteListener with a :
try {...} catch(e: RuntimeExecutionException) {...}
Just to avoid having to clear the PlayStore cache everytime I relaunch the app
After long time of debugging. I found, this is because of we are testing the app directly in mobile. Even though we generate and use signed apk, this error will occur.
The only way to get rid of this error is, we need to download the app from google play.
We can use Internal app sharing to test or simply publish our app.
Well, in my case we've cleared Google Play app cache and we didn't launch the Google Play before our app. You have to do it to download fresh data from the store, which is necessary for the SDK.
NOTE: I am not trying to update google play services in the emulator. I do not care that it is out of date. I mentioned it only to show that somehow logcat is reporting the actual build number, which I wish to access in the app.
Similar, but not the same as, How can I determine the version of Google Play services?
An app I'm developing using Android Studio 1.2.2 is experiencing a problem if the latest Google Play Services is not installed on the device, yet GoogleApiAvailability is not reporting a problem and so the code instructing the user to update is never called. If I manually tell the users to update play services in the play store with a manual link to https://play.google.com/store/apps/details?id=com.google.android.gms&hl=en, there is an update available, and the app functions correctly after they install it.
However I am unable to find a way to determine that the user needs to update via application code or the gradle build file.
In the gradle file I've specified: compile 'com.google.android.gms:play-services:7.5.0' and this is the latest version as far as I know. Android Studio does not indicate that I should update this line to a newer version.
The SDK manager reports the play services I have installed is "rev 25", and no update is available.
When I test in an emulator, the code works correctly, and in logcat I see the message: "W/GooglePlayServicesUtil: Google Play services out of date. Requires 7571000 but found 6774470". This is normal for the emulator since they haven't released new images yet, but it provides an interesting clue.
Is there a way to get this build number reported in item 3 above, programatically? If so, I could compare against that rather than using the isgooglePlayServicesAvailable method of GoogleApiAvailability -- which I'm already using, but is reporting success on devices that need an update.
I've managed to do a little digging and answer my own question. The following code will do what I (and perhaps others) want.
PackageInfo pi = getPackageManager().getPackageInfo("com.google.android.gms", 0);
if (pi.versionCode < VERSION_YOU_WANT)
{
// instruct user to update
}
What I've done is wrap this in the required exception handler and run it if the API check reports SUCCESS. If the version is too low I call the getErrorDialog just like when the API check fails, with ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED instead of the returned SUCCESS value.
Doing this may require you to update your minimum SDK target. For example both my phone(5.0.1) and tablet(4.2.2) report success from the API check, and going to the play store does not show an update for either one; However, the installed build on the table is 7895032 while on the phone it's 7895438.
This function will tell the user to update the GooglePlaServices if an update is available. You can start the registration process, if this function returns true
private boolean checkPlayServices()
{
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS)
{
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode))
GooglePlayServicesUtil.getErrorDialog(resultCode, this, 9000).show();
else
{
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}