1

我的Android应用程序在购买后崩溃。 在logcat中它显示了这个错误:Android在购买后的应用程序崩溃

Unable to start receiver com.blundell.test.BillingReceiver: java.lang.NullPointerException 

这是我的logcat:

07-09 11:10:22.901: I/BillingService(3369): Starting 
07-09 11:10:22.971: I/BillingService(3369): Service starting with onCreate 
07-09 11:10:22.971: I/BillingService(3369): Market Billing Service Successfully Bound 
07-09 11:10:23.031: I/BillingService(3369): Market Billing Service Connected. 
07-09 11:10:23.111: D/OpenGLRenderer(3369): Flushing caches (mode 0) 
07-09 11:10:25.031: I/BillingService(3369): isBillingSupported response was: RESULT_OK 
07-09 11:10:25.031: I/BillingService(3369): requestPurchase() 
07-09 11:10:25.051: I/BillingService(3369): current request is:1048018758395364016 
07-09 11:10:25.051: I/BillingService(3369): REQUEST_PURCHASE Sync Response code: RESULT_OK 
07-09 11:10:25.071: I/BillingService(3369): onPause()) 
07-09 11:10:25.181: D/OpenGLRenderer(3369): Flushing caches (mode 1) 
07-09 11:10:25.181: D/OpenGLRenderer(3369): Flushing caches (mode 0) 
07-09 11:10:35.151: I/BillingService(3369): Received action: com.android.vending.billing.IN_APP_NOTIFY 
07-09 11:10:35.151: I/BillingService(3369): notify got id: android.test.purchased 
07-09 11:10:35.151: I/BillingService(3369): getPurchaseInformation() 
07-09 11:10:35.151: I/BillingService(3369): Nonce generateD: -388618139592202345 
07-09 11:10:35.171: I/BillingService(3369): current request is:3124515352582500023 
07-09 11:10:35.171: I/BillingService(3369): GET_PURCHASE_INFORMATION Sync Response code: RESULT_OK 
07-09 11:10:35.601: I/BillingService(3369): Received action: com.android.vending.billing.RESPONSE_CODE 
07-09 11:10:35.601: I/BillingService(3369): checkResponseCode got requestId: 1048018758395364016 
07-09 11:10:35.601: I/BillingService(3369): checkResponseCode got responseCode: RESULT_OK 
07-09 11:10:36.011: I/BillingService(3369): Received action: com.android.vending.billing.PURCHASE_STATE_CHANGED 
07-09 11:10:36.011: I/BillingService(3369): purchaseStateChanged got signedData: {"nonce":-388618139592202345,"orders":[{"notificationId":"android.test.purchased","orderId":"transactionId.android.test.purchased","packageName":"org.sugarcrmclient","productId":"android.test.purchased","purchaseTime":1341812436261,"purchaseState":0}]} 
07-09 11:10:36.011: I/BillingService(3369): purchaseStateChanged got signature: 
07-09 11:10:36.011: I/BillingService(3369): signedData: {"nonce":-388618139592202345,"orders":[{"notificationId":"android.test.purchased","orderId":"transactionId.android.test.purchased","packageName":"org.sugarcrmclient","productId":"android.test.purchased","purchaseTime":1341812436261,"purchaseState":0}]} 
07-09 11:10:36.021: D/AndroidRuntime(3369): Shutting down VM 
07-09 11:10:36.021: W/dalvikvm(3369): threadid=1: thread exiting with uncaught exception (group=0x2b542210) 
07-09 11:10:36.041: E/AndroidRuntime(3369): FATAL EXCEPTION: main 
07-09 11:10:36.041: E/AndroidRuntime(3369): java.lang.RuntimeException: Unable to start receiver org.sugarcrmclient.market.BillingReceiver: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2146) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at android.app.ActivityThread.access$1500(ActivityThread.java:127) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at android.os.Handler.dispatchMessage(Handler.java:99) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at android.os.Looper.loop(Looper.java:137) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at android.app.ActivityThread.main(ActivityThread.java:4441) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at java.lang.reflect.Method.invokeNative(Native Method) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at java.lang.reflect.Method.invoke(Method.java:511) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at dalvik.system.NativeStart.main(Native Method) 
07-09 11:10:36.041: E/AndroidRuntime(3369): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at java.util.ArrayList.get(ArrayList.java:304) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at org.sugarcrmclient.market.BillingHelper.verifyPurchase(BillingHelper.java:250) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at org.sugarcrmclient.market.BillingReceiver.purchaseStateChanged(BillingReceiver.java:45) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at org.sugarcrmclient.market.BillingReceiver.onReceive(BillingReceiver.java:28) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2139) 
07-09 11:10:36.041: E/AndroidRuntime(3369):  ... 10 more 
+0

邮政logcat的请。 – Egor 2012-07-09 05:32:40

+0

发布完整的logcat并提供更多信息。 – 2012-07-09 05:38:31

+0

这是我的logcat我不知道我在哪里出错.... plz帮助和thnx提前... – Jpm 2012-07-09 05:50:34

回答

0

我可以看到这个IndexOutOdBoundException在你的日志,你可以检查不存取权限的任何位置到阵列中,不可用。下面突出显示的问题。

07-09 11:10:36.041: E/AndroidRuntime(3369): java.lang.RuntimeException: Unable to start receiver org.sugarcrmclient.market.BillingReceiver: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 
+0

先生,感谢您的帮助,BT会告诉我哪里可以是问题,因为我是新来的这我不能够解决这个.. plz帮助.. – Jpm 2012-07-09 05:57:31

+0

我从这里的代码:http://blog.blundell-apps.com/simple-inapp-billing-payment/#comment-529 – Jpm 2012-07-09 06:00:27

1

有问题的代码有安全检查,圆它只是你所描述的情况,你必须已经删除了相关检查:

  if(purchases != null && !purchases.isEmpty()){ 
        latestPurchase = purchases.get(0); 

        confirmTransaction(new String[]{latestPurchase.notificationId}); 
      } else { 
        Log.d(TAG, "BillingHelper.verifyPurchase error. purchase"); 
      }