2

我在我的開發人員控制檯中創建了5個項目(產品),但使用QueryInventory獲取項目的SkuDetails時,它只返回4個項目,所以我得到嘗試獲取未獲取產品的詳細信息時出現空指針異常。應用內結算查詢庫存返回一些(不是全部)項目

此外,有時它只返回其中一個項目,有時它不會返回任何項目。

有時Google有時可能只返回一些(而不是全部)產品?

我希望有人能幫助我弄清楚爲什麼:

在這個來看,我沒有得到ITEM4

內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); 

在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(); 

而所有五個項目顯示爲活動Google Play開發者控制檯。

這裏是logcat的輸出

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) 

回答

3

任何時候你添加一個新的項目到您通常需要3小時15分鐘的任何地方應用內商品的列表,以充分傳播到所有的Google Play服務器。發佈您的應用或更新後的APK也一樣。不幸的是,您需要耐心等待服務器處理您的請求。

+1

我希望那是......這些產品是在幾天前添加的。無論如何感謝 – fersarr

+0

你是否嘗試過調試器來查看來自Google的實際響應,以確保該項目實際上從響應中丟失,並且它不像SKU沒有拼寫錯誤? –

+0

我剛剛嘗試過,現在沒有錯別字。除此之外,它有時會工作(它提取所有項目),但有時它不會......現在再次發生 – fersarr

相關問題