在某些设备上,Iabhelper在Firebase测试实验室崩溃

时间:2017-06-23 14:24:08

标签: android firebase-test-lab

在Firebase测试实验室中测试我的应用时,我在2台设备上收到以下错误,与其他2台设备配合良好:

java.lang.RuntimeException: Unable to start activity ComponentInfo{MyActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.isEmpty()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2345)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2407)
at android.app.ActivityThread.access$800(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5321)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)


Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.isEmpty()' on a null object reference
at util.IabHelper.startSetup(IabHelper.java:267)
at MenuActivity.onCreate(MenuActivity.java:68)
at CameraActivity.onCreate(CameraActivity.java:19)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
... 10 more

所以这似乎是来自IabHelper初始化的问题,这是我设置它的代码:

String base64EncodedPublicKey = "MyKey";

    mHelper = new IabHelper(this, base64EncodedPublicKey);

    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
                           public void onIabSetupFinished(IabResult result)
                           {
                               if (!result.isSuccess()) {
                                   Log.d(TAG, "In-app Billing setup failed: " +
                                           result);
                               } else {
                                   Log.d(TAG, "In-app Billing is set up OK");
                               }
                           }
                       });

它在我的测试手机和我的2个alpha测试仪的手机上完美运行。有人对此有所了解吗?

1 个答案:

答案 0 :(得分:0)

所以这是一个已修复的错误,似乎我使用的是旧版本的IabHelper。万一有人找到它,这里你需要改变IabHelper.java,第267行:

替换:

if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {

使用:

List<ResolveInfo> resolveInfoList = mContext.getPackageManager().queryIntentServices(serviceIntent, 0);
if (resolveInfoList != null && !resolveInfoList.isEmpty()) {