ExperimentationConfigurator Fatal Exception: java.lang.NullPointerException

一.问题

之前因为facebook的SDK许久未更新
我们把Facebook SDK从4.11.0更新到4.30.0

  compile 'com.facebook.android:facebook-login:4.30.0'
  compile 'com.facebook.android:account-kit-sdk:4.30.0'

遇到了很多下面的这个问题

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'org.json.JSONArray org.json.JSONObject.getJSONArray(java.lang.String)' on a null object reference

       at com.facebook.accountkit.internal.ExperimentationConfigurator$2$1.onCompleted(SourceFile:93)
       at com.facebook.accountkit.internal.AccountKitGraphRequestAsyncTask.onPostExecute(SourceFile:188)
       at com.facebook.accountkit.internal.AccountKitGraphRequestAsyncTask.onPostExecute(SourceFile:42)
       at android.os.AsyncTask.finish(AsyncTask.java:651)
       at android.os.AsyncTask.access$500(AsyncTask.java:180)
       at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:7325)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

二.解决方案

1.是追溯调用栈的信息。

发现即使看不到调用栈,也追溯到了AccountKit.initialize()方法会间接的调用到了Crash的代码位置。

2.查看自己代码

果然有AccountKit.initialize()的相关调用。可是已经@Deprecated
然后去官网查了一下Changelog:
Facebook SDK for Android Changelog 4.x

调查发现在4.11.0-4.30.0之间的Changelog中有这样一段

4.19.0 - January 25, 2017

Facebook SDK

Modified
Facebook SDK is now auto initialized when the application starts. In most cases a manual call to FacebookSDK.sdkInitialize() is no longer needed. See upgrade guide for more details.
Activate App is now called during SDK initialization. To disable this feature please follow the directions in the upgrade guide.
Update the look and feel of LoginButton. See upgrade guide for more details.

Fixed
Possible memory leak in ActivityLifecycleTracker
Audience Network SDK

Added
Foregrounding/backgrounding listeners added to MediaView.

Fixed
Crash in NativeAdsManager fixed for Android API < 18.
onComplete method in MediaViewListener is now properly called when video playback finishes.
Crash when launching In-App Browser due to unsupported protocols.

Account Kit SDK

Modified
Account Kit SDK is now auto initialized when the application starts. In most cases a manual call to AccountKit.initialize() is no longer needed. See upgrade guide for more details.
Default Account Kit Instant Verification button as "Continue"

Fixed
Fixes crash bug where Android 7+ will throw exception if a file is marked WORLD_
Back arrow theming in entry screen
Setting focus on first entry field in confirmation code entry screen
VI translations
Checking permissions behavior on certain devices

Added
Logging for country codes

其中呢,注意到2条。4.19.0这个版本之后。AccountKit.initialize(),FacebookSdk.sdkInitialize(ctx);都已经@Deprecated掉了。查看sdk源码获知,SDK已经通过AccountKitInitProvider,FacebookInitProvider两个ContentProvider的方式,在更早的时间节点完成了初始化。所以就不用我们手动初始化了。抱着试试看的想法,去掉了。无用的初始化调用。结果BUG量直线下降。虽然fabric上还有个别情况发生。但是已经不再是Rank榜第一了。

虽然还是想不通。多调用一次init为什么会导致这样的问题。但还是算先改掉了这个BUG吧。

3.统计自动调用。

当然这个也不需要手动调用了。
AppEventsLogger.activateApp(this);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值