IabHelper onServiceConnected回调中的NullPointerException

时间:2015-05-13 14:29:38

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

当调用IabHelper#startSetup时,我看到异常

崩溃
05-08 14:01:35.448    5815-5815/com.test.test /AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.test.test, PID: 5815
java.lang.NullPointerException
        at com.test.android.lib.iab.util.IabHelper$1.onServiceConnected(IabHelper.java:247)
        at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1110)
        at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1127)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)

最近我注意到Play Services在我的所有设备上崩溃,看起来这个问题与此有关。重新启动设备以解决此问题。任何建议都非常感谢

当调用IabHelper#startSetup时,IabHelper会实例化服务

 billingHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
                @Override
                public void onIabSetupFinished(IabResult result) {
                    subscriber.onNext(result);
                    subscriber.onCompleted();
                }
            });

您可以在此处查看IabHelper文件https://gist.github.com/darussian/bf28c44970dc308f35b6#file-gistfile1-java-L247

0 个答案:

没有答案