【问题标题】:Playstore InAppBilling runtime exceptionPlaystore InAppBilling 运行时异常
【发布时间】:2017-07-24 08:42:58
【问题描述】:

我在 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 类。所以我猜我的代码首先无法启动服务。我做错了什么。

【问题讨论】:

  • 您可以参考这个related post。它表示您遇到这些错误可能是因为您试图在doInBackground() 上显示某些内容。 doInBackground 在无法执行任何 UI 工作的工作线程中运行(包括显示 Toast,这就是您正在做的事情)。相反,所有 UI 工作都应该在 onPostExecute() 上完成。另外,请确保您的manifest.xml 中有适当的permission

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


【解决方案1】:

我认为您正在测试应用计费,当时您遇到了这个问题。这是因为 google play 商店的错误版本而发生的。
所以不必担心。只需使用较旧的 google play 商店版本在应用程序中进行测试,它就可以正常工作。
欲了解更多信息,请访问this question

编辑:2017 年 8 月 11 日
现在在新的 google play store 版本 8.0.73.R-all [0] [PR] 162689464 google fix 这个crash 问题我有在我的设备上成功测试了它,所以现在你不再面临这个问题了。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-03
    • 2014-02-26
    • 2013-04-06
    • 2014-01-14
    • 2017-02-04
    • 2012-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多