Android Google billing integration - Client does not support ProductDetails - android

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.

Related

In-App Update gives InstallException (ERROR_API_NOT_AVAILABLE)

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.

Why Android update in-app always return UPDATE_NOT_AVAILABLE and version code is 0?

I'm testing update in-app from Android Studio with these instructions.
For test, I deleted my App and I setted a minor version code in gradle, then I installed this version of App from debug into my device.
The code above always return UPDATE_NOT_AVAILABLE.
Code:
private void checkForUpdates() {
// Creates instance of the manager.
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(MainActivity.this);
// Returns an intent object that you use to check for an update.
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
// Checks that the platform will allow the specified type of update.
Log.d(TAG, "upd_1:" + appUpdateManager.getAppUpdateInfo());
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
Log.d(TAG, "upd_2:" + appUpdateInfo.updateAvailability());
Log.d(TAG, "upd_3:" + appUpdateInfo.availableVersionCode());
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
// For a flexible update, use AppUpdateType.FLEXIBLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
// Request the update.
try {
appUpdateManager.startUpdateFlowForResult(
// Pass the intent that is returned by 'getAppUpdateInfo()'.
appUpdateInfo,
// Or 'AppUpdateType.FLEXIBLE' for flexible updates.
AppUpdateType.IMMEDIATE,
// The current activity making the update request.
this,
// Include a request code to later monitor this update request.
MY_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
});
}
Here is my Log:
This is the log of updateAvailability():
2019-12-05 17:00:39.436 3381-3381/org.my.app D/MainActivity: upd_2:1
This is the log of availableVersionCode():
2019-12-05 17:00:39.436 3381-3381/org.my.app D/MainActivity: upd_3:0
How i can test update in-app previos to upload my new version of this app?
Little late to the party here, but hopefully this can help someone else out in the future:
The reason you're getting a bad response is that both the new APK you are trying to provide an update to AND the APK you currently have installed must be signed by your production keys, AKA a release build. Using a debug build will cause this call to fail each time.
To test this correctly I'd recommend uploading release APKs to the Internal Test Track on the Google Developer Console. Something like this:
Upload version x.x.1 to internal test track, and use the link to download to your device
Upload bumped version x.x.2 to internal test track
Navigate to your app on the Play Store (should show an update available)
Go into your app and test the user flow you're expecting
More details here: In-App Update API showing UPDATE_NOT_AVAILABLE while testing on debugging device
At least you should download the app from Play Store. This because the device must know exact information about the application. After that other downgraded application is loaded, your code will work.
Just upload 2 versions with App Update feature with some differences. Then download first from Play Market and try to update from app, it should work.
In-app updates works only when you update version from Play Market.
Cheers.

How do I determine the actual build number for Google Play Services on Android?

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;
}

IabResult: Billing service unavailable on device. (response: 3:Billing Unavailable)

I'm trying to use In-App billing:
mIabHelper = new IabHelper(this, BILLING_KEY);
mIabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
#Override
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "Problem setting up In-app Billing: " + result);
}
}
});
And getting the error:
Problem setting up In-app Billing: IabResult: Billing service unavailable on device. (response: 3:Billing Unavailable)
Why? Tried to clear cache of the Play Store, didn't work for me.
Well we can't help you without having much information.So instead I'll try to do a checklist for you in case you missed something:
Are you testing on an emulator?Billing services should be tested on devices,BUT if you
really have to test on the emulator,make sure the emulator has google play installed and set up.This is very important!
Did you set the correct permission in the manifest? (com.android.vending.BILLING)
If you are still testing the app,did you get a test app licence from the playstore, imported the level in your SDK ,set up your licence verification library? (you can follow along here: setting up
On your activity onActivityResult did you correctly handle the activity result?As seen on the example from google you should do it this way:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.i(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// Pass on the activity result to the helper for handling
if (!inappBillingHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
else {
Log.i(TAG, "onActivityResult handled by IABUtil.");
}
}
Also having more information could be useful, like if you are testing on the emulator or device, the device name, the android version etc...
This error indicates that you're connecting to the in-app billing service on your device, but that the service doesn't support IAB version 3. It may be that your device's version of Google Play only supports version 2 of IAB. What version of Google Play is running on your device?
Is your version of Google Play otherwise functional (e.g., can you open the Google Play store)? Sometimes, if the date on your device is off, or there is some other problem, Google Play itself can go South.
Finally, what's in your logcat output? It would be easier to provide assistance if you provided more detail.
I got that error when I installed the App BEFORE I registered everything and set Google Play store up. Once I set the Google Play Store account up, the error went away.
Wipe helped me. Strange error.
The documentation for version 2.0 of the billing was actually more helpful than 3.0 for this one even though I'm using version 3.0 of the billing.
Here's how 2.0 describes it Response Code 3:
Indicates that In-app Billing is not available because the API_VERSION
that you specified is not recognized by the Google Play application or
the user is ineligible for in-app billing (for example, the user
resides in a country that prohibits in-app purchases).
For me I had to setup a test Google account on my phone first before testing. I forgot that step. Once I did that fixed it for me...
Look for Server Response Codes here:
http://developer.android.com/google/play/billing/v2/billing_reference.html
http://developer.android.com/google/play/billing/billing_reference.html
I found a problem to fix, try root with ur LuckyPatcher, open config Toggles -> Disable billing.
I had exactly this error when I removed all Google accounts from phone (thus wipe fixes because after wipe you probably set up an account after phone rebooted).
After I added an account I did not see this error.
Related issue What are the possibilities to get this error code 3 in InApp purchase?.
Had the same problem.
My device was rooted and ROM'ed with an older version of Google Market which did not self-update.
You can verify your the Market/Play version by looking at it in the AppManager.
I actually decided to use another device, but I guess otherwise I would have to find a way to upgrade the Market/Play version.
I got this error from wiping the Google Play cache. You have to reopen the Google Play app and accept the terms before it is functional for IAB again.
This is because the account which is currently logged in the device is not registered in Google Developer Console.
TO resolve this problem,
1. Go to your Google Developer Consol
2. In Account Detail Tab, enter the email address(which is in device) in "Gmail accounts with testing access" and press the save button on the top.
Thats it.
In my case I've set a different value for serviceIntent.setPackage("com.android.vending"); from IabHelper. Make sure you leave it with this value
I had that same error and then noticed my phone was in Airplane Mode! Once connectivity was restored, I was good to go.
IabHelper.java
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
It is an error if it is not possible to specify correctly the action and packageName to IInAppBillingService.aidl.
Have come up with the solution.
Try the below 3 steps:
Clear the cache of GooglePlay app and Google Play services app.
Remove IInAppBillingService.aidl file.
Copy the above file again from sdk folder and paste it to the aidl folder in my app.
This problem usually occurs when we copy the aidl file from one project to another project.

Is there a way to understand if Android App Update was installed by users?

I just published an update to my Android App on Android Market and Android market sent notification for the update which is fine. But I am trying to figure out if there is a way to know if the users installed the update that was published?
I do not see any details in Android Market Developer console.
These are users who were using the earlier version already not new users. Any insight would be very helpful.
You can track utilization with Google Analytics.
I'm doing this inside a changelist pop-up for the new version:
if (!appPrefs.getAppVer().equals(getAppVerName())) {
...
tracker.trackEvent("Home Screen", "Click", getAppVerName(), 1);
appPrefs.saveAppVer(getAppVerName());
appPrefs.saveAcceptedUsageAggrement(false);
}
You can see that I set the AcceptedUsageAgreement to false so that gets displayed after an update too ;)
where getAppVerName() is ...
public String getAppVerName() {
String text;
try {
text = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (NameNotFoundException e) {
text = "Version Not Found";
}
return text;
}
You can kinda see this if you're using Flurry. If you're not using Flurry, it's really easy to set up (and it's free). Flurry tags user sessions with the version of your app that's running and you can filter your stats on the website by version. So, select the previous version, and you can see a chart of the number of users and sessions per day of that version. This won't tell you exactly how many people upgraded, but you can get a feel for who didn't.
No there is no way to know if a user installed an update or force a user to install an update without adding special code to your app to force them to do so.
Integrate Crashlytics into your app. This will give you a complete report of active users and crashes per day for each version you release.
Tutorial to integrate Crashlytics to your app

Categories

Resources