Playstore InAppBilling运行时异常

时间:2017-07-24 08:42:58

标签: android google-play google-play-services in-app-billing

我在Fragment中以这样的方式启动InAppBillingService

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent serviceIntent =
            new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    getActivity().bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);

}

每当我尝试购买商品时,我都会收到此错误

FATAL EXCEPTION: AsyncTask #6
                                               Process: com.android.vending, PID: 15192
                                               java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                   at android.os.AsyncTask$3.done(AsyncTask.java:325)
                                                   at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                   at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                   at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                   at java.lang.Thread.run(Thread.java:761)
                                                Caused by: java.lang.NullPointerException: Attempt to read from field 'long com.google.wireless.android.finsky.dfe.nano.an.b' on a null object reference
                                                   at com.google.android.finsky.billing.lightpurchase.s.a(SourceFile:5)
                                                   at com.google.android.finsky.billing.lightpurchase.h.doInBackground(SourceFile:27)
                                                   at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                   at java.util.concurrent.FutureTask.run(FutureTask.java:237)

代码执行永远不会到达mServiceConn类。所以我猜我的代码首先无法启动服务。我做错了什么。

1 个答案:

答案 0 :(得分:0)

我认为您正在使用应用计费进行测试,当时您遇到了这个问题。这只是因为Google Play商店的bugy版本而发生的 所以不用担心。只需使用较旧的Google Play商店版本在应用中进行测试,它就可以正常使用 有关更多信息,请访问this question

编辑:2017年8月11日
现在新的谷歌游戏商店版本 8.0.73.R-所有[0] [公关] 162689464 谷歌修复崩溃问题我有在我的设备上成功测试了它,所以现在你不再面对这个问题了。 :)