ExperimentationConfigurator Fat

作者: Jamin_正宗红罐辣酱 | 来源:发表于2018-02-07 11:01 被阅读22次

    一.问题

    之前因为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);

    相关文章

      网友评论

        本文标题:ExperimentationConfigurator Fat

        本文链接:https://www.haomeiwen.com/subject/tueozxtx.html