libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
225 stars 82 forks source link

Android 2.3.3: Error refreshing inventory (querying prices of items). #32

Closed wsrdzg closed 9 years ago

wsrdzg commented 9 years ago

gdx-pay works fine on my Nexus 5 (5.0.2) and Nexus 7 2012 (5.0.1) but on my Galaxy S1 (2.3.3) I get the following exception when the app starts.

01-01 01:10:28.023    1232-1280/com.example.game E/OpenIAB﹕ queryInventoryAsync() Error :
    org.onepf.oms.appstore.googleUtils.IabException: Error refreshing inventory (querying prices of items). (response: 6:Error)
            at org.onepf.oms.appstore.googleUtils.IabHelper.queryInventory(IabHelper.java:588)
            at org.onepf.oms.OpenIabHelper.queryInventory(OpenIabHelper.java:1371)
            at org.onepf.oms.OpenIabHelper$17.run(OpenIabHelper.java:1423)
            at java.lang.Thread.run(Thread.java:1019)
01-01 01:10:28.093    1232-1283/com.example.game E/OpenIAB﹕ queryInventoryAsync() Error :
    org.onepf.oms.appstore.googleUtils.IabException: Error refreshing inventory (querying prices of items). (response: 6:Error)
            at org.onepf.oms.appstore.googleUtils.IabHelper.queryInventory(IabHelper.java:588)
            at org.onepf.oms.OpenIabHelper.queryInventory(OpenIabHelper.java:1371)
            at org.onepf.oms.OpenIabHelper$17.run(OpenIabHelper.java:1423)
            at java.lang.Thread.run(Thread.java:1019)
01-01 01:10:28.097    1232-1232/com.example.game D/AndroidRuntime﹕ Shutting down VM
01-01 01:10:28.097    1232-1232/com.example.game W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40015578)
01-01 01:10:28.117    1232-1232/com.example.game E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NullPointerException
            at com.badlogic.gdx.pay.android.openiab.PurchaseManagerAndroidOpenIAB$3.onQueryInventoryFinished(PurchaseManagerAndroidOpenIAB.java:356)
            at org.onepf.oms.OpenIabHelper$17$1.run(OpenIabHelper.java:1435)
            at android.os.Handler.handleCallback(Handler.java:587)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:123)
            at android.app.ActivityThread.main(ActivityThread.java:3687)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
            at dalvik.system.NativeStart.main(Native Method)
alex-dorokhov commented 9 years ago

The same for me for Android 2.3.6 (gdx-pay 0.3.0)

wsrdzg commented 9 years ago

I use 0.4.0-SNAPSHOT because 0.3.0 has some other bugs.

noblemaster commented 9 years ago

Looks like there is others with the same problem (OpenIAB backend): http://stackoverflow.com/questions/17154020/error-refreshing-iventory-querying-prices-of-items-response-6error

Basically each time we start the purchase manager, we query all the purchases and obtain an inventory list. Given Stackoverflow above, obtaining the inventory will fail if there is no internet connection available. Do you have internet (e.g. WiFi) on the two devices where it failed? Does the error still occur if you are connected to the internet?

And yes, please use 0.4.0-SNAPSHOT!

alex-dorokhov commented 9 years ago

I had this problem in another project, while using plain IabHelper from Google. I can confirm that a lot of crashes was caused by querying inventory at the start of the app. It can, however succeed on the second attempt. So, we had decided to do not query inventory at the start but only if the user opens the shop screen, because most of the time you need inventory only for prices. We still query for purchases at the start. This reduced number of crashes. It's anyway a good idea to check IabResult.isSuccess in PurchaseManagerAndroidOpenIAB:351 before using inventory, I think!

While using gdx-pay 0.3.0 I had another error however, but it was fixed I hope. Sorry.

noblemaster commented 9 years ago

Good point! It definitely makes sense to load the inventory again if it fails the first time around.

I put it onto my to do list. I don't have time right now, but I'll fix it later :)