Niko surya pratama
Niko surya pratama

Reputation: 107

android - The SDK has not been initialized, make sure to call AccountKit.initialize() first

I got this error when using Facebook Account Kit. When I debug my program the method Accountkit.GetCurrentAccessToken()!=null causes this error. When I remove this. Then somewhere but not in the code I write causes this error also. I have tried editing the manifest.xml but I had no luck. Can anyone help me fix this ?

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.featuring.beta.featuringbeta, PID: 26749
              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.featuring.beta.featuringbeta/com.facebook.accountkit.ui.AccountKitActivity}: 500: Initialization error: 501: The SDK has not been initialized, make sure to call AccountKit.initialize() first
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2330)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
                  at android.app.ActivityThread.access$800(ActivityThread.java:151)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:135)
                  at android.app.ActivityThread.main(ActivityThread.java:5261)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:372)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:939)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:734)
               Caused by: 500: Initialization error: 501: The SDK has not been initialized, make sure to call AccountKit.initialize() first
                  at com.facebook.accountkit.internal.Validate.sdkInitialized(Validate.java:53)
                  at com.facebook.accountkit.internal.Initializer.getLoginManager(Initializer.java:199)

Thanks.

Note I made a new project with Accountkit it works fine. When I put the code in my project for the signup and login, it causes this error.

Upvotes: 1

Views: 2402

Answers (1)

Arslan Maqbool
Arslan Maqbool

Reputation: 529

Make Sure you initialize the account kit in application class like this

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        AccountKit.initialize(getApplicationContext());
    }
}

After that in Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.you.yourapp">

    <application
        android:name=".MyApplication"

Upvotes: 0

Related Questions