java.lang.IllegalStateException: Orca SharedPreferences used before initialized
Asked Answered
S

1

6

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

and it's throwing the exception:

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!

Scheelite answered 18/9, 2013 at 13:39 Comment(1)
if you are facing the same issue, you can also subscribe to the bug report in the facebook developer console: developers.facebook.com/bugs/…Scheelite
S
7

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:

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

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...

Scheelite answered 24/9, 2013 at 8:28 Comment(2)
Just to let you know that this has been fixed in Facebook for Android SDK v3.5.2. See the changelogSteve
that´s great @RahulParsani!Scheelite

© 2022 - 2024 — McMap. All rights reserved.