我在项目中添加了一个新的计费库。
compile 'com.android.billingclient:billing:1.0'
向我的项目添加了BillingManager.java类
我有很多例外,详情来自Crashlytics:
Fatal Exception: java.lang.RuntimeException
Unable to resume activity {com.domain.app/com.domain.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
Caused by java.lang.NullPointerException
Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
com.domain.app.BillingManager$4.run
com.domain.app.BillingManager.executeServiceRequest (Unknown Source)
com.domain.app.BillingManager.executeServiceRequest (Unknown Source)
com.domain.app.MainActivity.onResume (Unknown Source)
TXT模式:
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.domain.app/com.domain.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3647)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3687)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1629)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6623)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
MainActivity的OnResume()包含以下代码:
if (mBillingManager != null && mBillingManager.getBillingClientResponseCode() == BillingClient.BillingResponse.OK) {
mBillingManager.queryPurchases();
}
我该如何解决?大约1%的DAU会遇到这种问题。