java.lang.IllegalStateException:逆戟鲸共享preferences使用前初始化 [英] java.lang.IllegalStateException: Orca SharedPreferences used before initialized

查看:385
本文介绍了java.lang.IllegalStateException:逆戟鲸共享preferences使用前初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经集成了Facebook的SDK为Android V3.5在我的应用程序,其中包括安装出版code:

I have integrated the Facebook SDK for android v3.5 in my app and included the install publishing code:

com.facebook.AppEventsLogger.activateApp(this);

不过,我收到了很多造成事故的:

But I am receiving a lot of crashes caused by:

Settings.java line 418
com.facebook.Settings.getAttributionId

和它抛出异常:

java.lang.IllegalStateException: Orca SharedPreferences used before initialized

我一直在试图重现崩溃,但没有成功。有没有人遇到过这个问题?我只是想知道:

I have been trying to reproduce the crash with no success. Has anybody encountered this issue? I just want to know if:

/* Only activate FaceBook publish install if the user has the FaceBook app installed */
if (com.facebook.Settings.getAttributionId(getContentResolver()) != null){
    com.facebook.AppEventsLogger.activateApp(this);
}

这将解决这一问题?谢谢!

this would fix the problem? Thanks!

推荐答案

我们终于通过捕捉异常,并避免为未安装Facebook应用程序的设备得到了激活修复了这个问题。 Facebook的开发人员回答我们:

We finally fixed this issue by catching the exception and avoiding that devices without an installed facebook app got activated. A facebook developer answered us:

用户需要有Facebook的Andr​​oid应用程序安装在他们的设备上登录的activateApp正常工作。

"The user needs to have the Facebook Android app installed on their device and logged in for activateApp to function properly."

这是在code,我们终于用它isn't崩溃了:

This is the code we finally used and it isn´t crashing anymore:

try{
        /* Only activate FaceBook publish install if the user has the FaceBook app installed */
        if (com.facebook.Settings.getAttributionId(getContentResolver()) != null){
        com.facebook.AppEventsLogger.activateApp(this);
        }
    } catch (IllegalStateException e){
        Log.d(TAG, "Facebook Setting Exception again!");
    }

我希望这可以帮助别人......

I hope this helps others...

这篇关于java.lang.IllegalStateException:逆戟鲸共享preferences使用前初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆