观众网络sdk内部致命的NumberFormatException崩溃

时间:2016-11-09 11:33:46

标签: android android-facebook facebook-audience-network

这是每个广告加载的堆栈跟踪

Fatal Exception: java.lang.NumberFormatException: Invalid int: "false"
   at java.lang.Integer.invalidInt(Integer.java:138)
   at java.lang.Integer.parse(Integer.java:410)
   at java.lang.Integer.parseInt(Integer.java:367)
   at java.lang.Integer.parseInt(Integer.java:334)
   at java.lang.Integer.valueOf(Integer.java:525)
   at com.facebook.ads.internal.h.a(Unknown Source)
   at com.facebook.ads.internal.h.h(Unknown Source)
   at com.facebook.ads.internal.j.a.a(Unknown Source)
   at com.facebook.ads.internal.j.a$b.run(Unknown Source)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:135)
   at android.app.ActivityThread.main(ActivityThread.java:5253)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.ru

有其他人得到这个还是仅仅是我?

1 个答案:

答案 0 :(得分:1)

发生此错误是因为FB AN SDK将字符串“false”解析为整数,并且此字符串“false”来自SharedPreferences,因此您可以注册一个侦听器以将值更改为整数,如下所示:

<call when app started>
final SharedPreferences sp = getSharedPreferences("com.facebook.ads.FEATURE_CONFIG", 0);
        fixFbBug(sp);
        listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
            @Override
            public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
                fixFbBug(sp);
            }
        };
        sp.registerOnSharedPreferenceChangeListener(listener);


private void fixFbBug(SharedPreferences sp){
        final String a = sp.getString("visible_area_percentage", "0");
        Log.d("wzw===","IN FIX ::" + a);
        try {
            Integer.valueOf(a);
        } catch (Exception e) {
            sp.edit().putString("visible_area_percentage", "50").commit();
        }
    }