Android Logout causes nullPointerException in restoreAuthKeysFromPreferences()

I am logged in with as a facebook user. pressing the logout button causes this exception: (also see attached image)

java.lang.NullPointerException
at com.backendless.AndroidBackendlessPrefs.restoreAuthKeysFromPreferences(AndroidBackendlessPrefs.java:103)
at com.backendless.AndroidBackendlessPrefs.getAuthKeys(AndroidBackendlessPrefs.java:96)
at com.backendless.AndroidBackendlessPrefs.getApplicationId(AndroidBackendlessPrefs.java:51)
at com.backendless.Backendless.getApplicationId(Backendless.java:175)
at com.backendless.UserService.logout(UserService.java:389)
at com.taldroid.apps.tapextreme.ui.fragments.InviteFragment$1.onClick(InviteFragment.java:40)
at android.view.View.performClick(View.java:4377)
at android.view.View$PerformClick.run(View.java:18044)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5306)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)

Hi Tal. this is not good :frowning: We’ll look into it.

Mark

Hi, Tal,

We could reproduce your problem using neither Easy Facebook login nor Facebook SDK.
Under what circumstances does the error occur? Did you select “Do not keep activities” option in Developer Options?

Could you please share part of your project for us?
Send it to my email artur.dzidzoiev@themidnightcoders.com.

Regards,
Artur.

Hi Tal,

Thank you for your letter.

When you call Backendless.initApp you reset your credential store so that is the reason why you got NPE.
You do not need to call initApp() in LoginActivity. It would be better to move the initApp code to global
Application#onCreate().

This message is duplicated to your email.

Regards,

Artur.

When you call Backendless.initApp you reset your credential…

What does that mean? Can I init the credentials somehow at a given point in my app?

It means the initApp method should not be called after the login method. It should be called only once in the app, preferably in the “Application#onCreate()” method as suggested by Artur.