4

I have created 5 items (products) in my developer console but when using QueryInventory to get the SkuDetails of the items, it only returns 4 of them, so I get a Null Pointer Exception when trying to get the details of the not-fetched product.

Also, sometimes it only returns one of the items, and sometimes it doesn't return any of them.

Is it possible that sometimes Google just returns some (and not all) of the products?

I hope someone can help me figure out why:

In this run I didn't get item4

Inside mHelper.startSetup

additionalSkuList.add(SKU_item1); 
additionalSkuList.add(SKU_item2);
additionalSkuList.add(SKU_item3);
additionalSkuList.add(SKU_item4); // this one is missing in the response
additionalSkuList.add(SKU_item5);

mHelper.queryInventoryAsync(true, additionalSkuList,mQueryFinishedListener);

In the queryInventoryListener:

   String item1Price =inventory.getSkuDetails(SKU_item1).getPrice();
   String item2Price =inventory.getSkuDetails(SKU_item2).getPrice();
   String item3Price =inventory.getSkuDetails(SKU_item3).getPrice();
   String item4Price =inventory.getSkuDetails(SKU_item4).getPrice(); //Null Pointer Exc. HERE
   String item5Price =inventory.getSkuDetails(SKU_item5).getPrice();

And all five of the items appear as active in the Google Play Developers Console.

Here is the Logcat output

05-19 19:33:49.048: D/BillingTest(23534): Starting IAB setup.
05-19 19:33:49.048: D/IabHelper(23534): Starting in-app billing setup.
05-19 19:33:49.058: D/IabHelper(23534): Billing service connected.
05-19 19:33:49.058: D/IabHelper(23534): Checking for in-app billing 3 support.
05-19 19:33:49.068: D/IabHelper(23534): In-app billing version 3 supported for com.billingtest.billingtest2
05-19 19:33:49.068: D/IabHelper(23534): Subscriptions AVAILABLE.
05-19 19:33:49.068: I/BillingTest(23534): IAB Setup finished.
05-19 19:33:49.068: I/BillingTest(23534): Setup successful. Querying inventory.
05-19 19:33:49.068: I/BillingTest(23534): Starting to query
05-19 19:33:49.068: D/IabHelper(23534): Starting async operation: refresh inventory
05-19 19:33:49.068: D/IabHelper(23534): Querying owned items, item type: inapp
05-19 19:33:49.068: D/IabHelper(23534): Package name: com.billingtest.billingtest2
05-19 19:33:49.068: D/IabHelper(23534): Calling getPurchases with continuation token: null
05-19 19:33:49.078: D/IabHelper(23534): Owned items response: 0
05-19 19:33:49.078: D/IabHelper(23534): Continuation token: null
05-19 19:33:49.078: D/IabHelper(23534): Querying SKU details.
05-19 19:33:49.078: D/IabHelper(23534): query SKU: item1
05-19 19:33:49.078: D/IabHelper(23534): query SKU: item2
05-19 19:33:49.078: D/IabHelper(23534): query SKU: item3
05-19 19:33:49.078: D/IabHelper(23534): query SKU: item4
05-19 19:33:49.078: D/IabHelper(23534): query SKU: item5
05-19 19:19:23.755: D/IabHelper(21969): Got sku details: SkuDetails:{"title":"item1 (BillingTest)","price":"£0.59","type":"inapp","description":"item1desc","price_amount_micros":990000,"price_currency_code":"USD","productId":"item1"}
05-19 19:19:23.755: D/IabHelper(21969): Got sku details: SkuDetails:{"title":"item2(BillingTest)","price":"£0.59","type":"inapp","description":"item2desc","price_amount_micros":990000,"price_currency_code":"USD","productId":"item2"}
05-19 19:19:23.765: D/IabHelper(21969): Got sku details: SkuDetails:{"title":"item3(BillingTest)","price":"£0.59","type":"inapp","description":"item3desc","price_amount_micros":990000,"price_currency_code":"USD","productId":"item3"}
05-19 19:19:23.765: D/IabHelper(21969): Got sku details: SkuDetails:{"title":"item5(BillingTest)","price":"£1.78","type":"inapp","description":"item5desc","price_amount_micros":2990000,"price_currency_code":"USD","productId":"item5"}
05-19 19:19:23.765: D/IabHelper(21969): Querying owned items, item type: subs
05-19 19:19:23.765: D/IabHelper(21969): Package name: com.billingtest.billingtest2
05-19 19:19:23.765: D/IabHelper(21969): Calling getPurchases with continuation token: null
05-19 19:19:23.775: D/IabHelper(21969): Owned items response: 0
05-19 19:19:23.775: D/IabHelper(21969): Continuation token: null
05-19 19:19:23.775: D/IabHelper(21969): Querying SKU details.
05-19 19:19:23.775: D/IabHelper(21969): query SKU: item1
05-19 19:19:23.775: D/IabHelper(21969): query SKU: item2
05-19 19:19:23.775: D/IabHelper(21969): query SKU: item3
05-19 19:19:23.775: D/IabHelper(21969): query SKU: item4
05-19 19:19:23.775: D/IabHelper(21969): query SKU: item5
05-19 19:19:23.785: D/OpenGLRenderer(21969): Enabling debug mode 0
05-19 19:19:23.805: D/IabHelper(21969): Ending async operation: refresh inventory
05-19 19:19:23.885: I/BillingTest(21969): Inside QueryInventoryFinished Listener
05-19 19:19:23.885: D/BillingTest(21969): Query inventory was successful.
05-19 19:19:23.885: D/AndroidRuntime(21969): Shutting down VM
05-19 19:19:23.885: W/dalvikvm(21969): threadid=1: thread exiting with uncaught exception (group=0x415e9ba8)
05-19 19:19:23.885: E/AndroidRuntime(21969): FATAL EXCEPTION: main
05-19 19:19:23.885: E/AndroidRuntime(21969): Process: com.billingtest.billingtest2, PID: 21969
05-19 19:19:23.885: E/AndroidRuntime(21969): java.lang.NullPointerException
05-19 19:19:23.885: E/AndroidRuntime(21969):    at com.billingtest.billingtest2.MainActivity$1.onQueryInventoryFinished(MainActivity.java:250)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at com.billingtest.billingtest2.util.IabHelper$2$1.run(IabHelper.java:633)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at android.os.Handler.handleCallback(Handler.java:733)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at android.os.Handler.dispatchMessage(Handler.java:95)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at android.os.Looper.loop(Looper.java:136)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at android.app.ActivityThread.main(ActivityThread.java:5017)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at java.lang.reflect.Method.invokeNative(Native Method)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at java.lang.reflect.Method.invoke(Method.java:515)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-19 19:19:23.885: E/AndroidRuntime(21969):    at dalvik.system.NativeStart.main(Native Method)

fersarr
  • 3,399
  • 3
  • 28
  • 35

1 Answers1

2

Any time you add a new item to your list of In-app Products it usually takes anywhere from 15 minutes to 3 hours to fully propagate to all of the Google Play servers. Same goes for publishing your app or an updated APK. Unfortunately you'll just need to be patient and give the servers time to process your request.

Brian Shamblen
  • 4,653
  • 1
  • 23
  • 37
  • 2
    I wish that was it...these products were added days ago. Thanks anyways – fersarr May 19 '14 at 23:33
  • Have you tried stepping through the debugger to look at the actual response from Google, to make sure the item is actually missing from the response and it's not something like the SKU not misspelled? – Brian Shamblen May 19 '14 at 23:47
  • I just tried that now and there are no typos. Besides it does work sometimes (it fetches all items) but sometimes it doesn't... It's happening again now – fersarr May 20 '14 at 00:20
  • 1
    If it's been days and you're still seeing intermittent differences in the response it sounds like you may need to contact Google. There may have been an issue propagating your changes to all of their servers. If the code works sometimes I don't think it's an issue with your code. – Brian Shamblen May 20 '14 at 00:26
  • 2
    Hi again @Brian! I came to tell you that these last 2 days it has been working without problem, so you were right, I just had to wait. It took a long time :S – fersarr May 23 '14 at 23:33
  • waited for almost 3 days... still not working.. if I use the android.test.purchased as SKU's it works fine.. – A. Adam Sep 05 '15 at 18:27