Android In-App Billing - queryInventoryAsync returns 0 result

I am disappointed with the in-app billing process. I created a new application in the dev console, added an inapp product called "P1", which is currently active; I downloaded my application to the store in alpha, then switched to beta, added a tester account and installed apk on a device (tablet) signed with a tester account and another with a dev account.

Now, I would like to request from the store to get information, such as the price of a non-skus. Here is my code from my activity :

private void istantiate() { List<String> tmp = new List<String>(); tmp.add("P1"); final List<String> skus = tmp; mHelper = new IabHelper(mContext, base64EncodedPublicKey); // enable debug logging (for a production application, you should set this to false). mHelper.enableDebugLogging(true); //create listener bListener = new BillingListener(mHelper, mContext); // Start setup. This is asynchronous and the specified listener will be called once setup completes. mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { // There was a problem. return; } getInventory(skus); } }); } ... private void getInventory(List<String> skuList) { // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) return; // IAB is fully set up. Now, let get an inventory of stuff we own. mHelper.queryInventoryAsync(true, skuList, bListener.mQueryFinishedListener); } 

Then, when the request is complete, this piece of code is called:

  IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() { public void onQueryInventoryFinished(IabResult result, Inventory inventory) { if (result.isFailure()) { // handle error return; } ... } }; 

But the returned inventory is empty. Here logcat :

  12-13 11:21:36.977: D/IabHelper(6034): Billing service connected. 12-13 11:21:36.977: D/IabHelper(6034): Checking for in-app billing 3 support. 12-13 11:21:36.987: D/IabHelper(6034): In-app billing version 3 supported for *** 12-13 11:21:36.987: D/IabHelper(6034): Subscriptions AVAILABLE. 12-13 11:21:36.987: D/IabHelper(6034): Starting async operation: refresh inventory 12-13 11:21:36.987: D/IabHelper(6034): Querying owned items, item type: inapp 12-13 11:21:36.987: D/IabHelper(6034): Package name: *** 12-13 11:21:36.987: D/IabHelper(6034): Calling getPurchases with continuation token: null 12-13 11:21:36.997: D/IabHelper(6034): Owned items response: 0 12-13 11:21:36.997: D/IabHelper(6034): Continuation token: null 12-13 11:21:36.997: D/IabHelper(6034): Querying SKU details. 12-13 11:21:37.097: D/IabHelper(6034): Querying owned items, item type: subs 12-13 11:21:37.097: D/IabHelper(6034): Package name: *** 12-13 11:21:37.097: D/IabHelper(6034): Calling getPurchases with continuation token: null 12-13 11:21:37.097: D/IabHelper(6034): Owned items response: 0 12-13 11:21:37.097: D/IabHelper(6034): Continuation token: null 12-13 11:21:37.097: D/IabHelper(6034): Querying SKU details. 12-13 11:21:37.097: D/IabHelper(6034): Ending async operation: refresh inventory 

This is about a week after the release of my inapp product, so it is not a matter of time. I tried to clear the application data and restart the device.

Change Everything works fine using android.test.purchased as test sku.
Edit 2 : SKUs are unmanageable

+7
android google-play-services in-app-billing in-app-purchase
source share
3 answers

I also had a problem, but it was fixed after I cleared the application data for the Google Play application. Using adb:

 adb shell pm clear com.android.vending 
+4
source share

I believe this is due to caching in the Google Play app. Typically, the Google Play app cache is updated every 24 hours.

Decision

@poqueque works if you want to clear the cache through the command line. You can also use the application settings on the phone and clear the data / cache of the Google Play application. Be sure to log into your Google Play account after this.

Does anyone know which solution to force update the Google Play cache by purchasing a code or request without using the cache to update the information?

+1
source share

"Response to owned items" reports the response code, which in this case is BILLING_RESPONSE_RESULT_OK with a value of 0.

Looking at the code IabHelper.queryPurchases and IabHelper.getSkuDetails, I offer you a good place to get data using "inventory.hasDetails (" P1 ") or" inventory.getSkuDetails ("P1") in onQueryInventoryFinished.

0
source share

All Articles