Android应用内的计费有时会崩溃/有时会工作

时间:2017-12-01 17:48:07

标签: android in-app-purchase in-app-billing

我正在尝试为我的应用设置应用内结算,而我只是编辑TrivialDrive(仅需要购买天然气,因此我会删除其他购买代码)。所以我第一次运行它它完美地工作,我甚至完成了购买。但下次我运行它(我100%确定我没有改变任何代码)当我选择购买按钮时应用程序崩溃了!

我试过:invalidate and restart android studio-重新启动我的手机,但没有任何改变。

>     java.lang.IllegalStateException: Could not execute method of the activity
>                                                                                 at android.view.View$1.onClick(View.java:3688)
>                                                                                 at android.view.View.performClick(View.java:4293)
>                                                                                 at android.view.View$PerformClick.run(View.java:17535)
>                                                                                 at android.os.Handler.handleCallback(Handler.java:725)
>                                                                                 at android.os.Handler.dispatchMessage(Handler.java:92)
>                                                                                 at android.os.Looper.loop(Looper.java:153)
>                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5299)
>                                                                                 at java.lang.reflect.Method.invokeNative(Native Method)
>                                                                                 at java.lang.reflect.Method.invoke(Method.java:511)
>                                                                                 at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
>                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
>                                                                                 at dalvik.system.NativeStart.main(Native Method)
>                                                                              Caused by: java.lang.reflect.InvocationTargetException
>                                                                                 at java.lang.reflect.Method.invokeNative(Native Method)
>                                                                                 at java.lang.reflect.Method.invoke(Method.java:511)
>                                                                                 at android.view.View$1.onClick(View.java:3683)
>                                                                                 at android.view.View.performClick(View.java:4293) 
>                                                                                 at android.view.View$PerformClick.run(View.java:17535) 
>                                                                                 at android.os.Handler.handleCallback(Handler.java:725) 
>                                                                                 at android.os.Handler.dispatchMessage(Handler.java:92) 
>                                                                                 at android.os.Looper.loop(Looper.java:153) 
>                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5299) 
>                                                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
>                                                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
>                                                                                 at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
>                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
>                                                                                 at dalvik.system.NativeStart.main(Native Method) 
>                                                                              Caused by: java.lang.IllegalStateException: Can't start async
> operation (launchPurchaseFlow) because another async operation(refresh
> inventory) is in progress.
>                                                                                 at util.IabHelper.flagStartAsync(IabHelper.java:819)
>                                                                                 at util.IabHelper.launchPurchaseFlow(IabHelper.java:373)
>                                                                                 at util.IabHelper.launchPurchaseFlow(IabHelper.java:338)
>                                                                                 at
> kalamat.fun4ever.com.word2.buying.onBuyGasButtonClicked(buying.java:209)
>                                                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
>                                                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
>                                                                                 at android.view.View$1.onClick(View.java:3683) 
>                                                                                 at android.view.View.performClick(View.java:4293) 
>                                                                                 at android.view.View$PerformClick.run(View.java:17535) 
>                                                                                 at android.os.Handler.handleCallback(Handler.java:725) 
>                                                                                 at android.os.Handler.dispatchMessage(Handler.java:92) 
>                                                                                 at android.os.Looper.loop(Looper.java:153) 
>                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5299) 
>                                                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
>                                                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
>                                                                                 at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
>                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
>                                                                                 at dalvik.system.NativeStart.main(Native Method)  12-01 21:15:29.052
> 27771-27777/kalamat.fun4ever.com.word2 D/jdwp: processIncoming

这是“buy.java:209' :

  mHelper.launchPurchaseFlow(this, SKU_GAS, RC_REQUEST,
                mPurchaseFinishedListener, payload);

1 个答案:

答案 0 :(得分:0)

因为另一项操作尚未完成,可能您已与Google服务器断开连接。如果mservices为空,则发生崩溃时检查。