You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.vickychijwani.spectre/me.vickychijwani.spectre.view.PostListActivity}: java.lang.RuntimeException: Could not dispatch event: class me.vickychijwani.spectre.event.LoadUserEvent to handler [EventHandler public void me.vickychijwani.spectre.network.NetworkService.onLoadUserEvent(me.vickychijwani.spectre.event.LoadUserEvent)]: Attempt to invoke interface method 'void me.vickychijwani.spectre.network.GhostApiService.getCurrentUser(retrofit.Callback)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.RuntimeException: Could not dispatch event: class me.vickychijwani.spectre.event.LoadUserEvent to handler [EventHandler public void me.vickychijwani.spectre.network.NetworkService.onLoadUserEvent(me.vickychijwani.spectre.event.LoadUserEvent)]: Attempt to invoke interface method 'void me.vickychijwani.spectre.network.GhostApiService.getCurrentUser(retrofit.Callback)' on a null object reference
at com.squareup.otto.Bus.throwRuntimeException(Bus.java:458)
at com.squareup.otto.Bus.dispatch(Bus.java:388)
at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:369)
at com.squareup.otto.Bus.post(Bus.java:338)
at me.vickychijwani.spectre.view.PostListActivity.onCreate(PostListActivity.java:82)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void me.vickychijwani.spectre.network.GhostApiService.getCurrentUser(retrofit.Callback)' on a null object reference
at me.vickychijwani.spectre.network.NetworkService.onLoadUserEvent(NetworkService.java:99)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.squareup.otto.EventHandler.handleEvent(EventHandler.java:89)
at com.squareup.otto.Bus.dispatch(Bus.java:386)
at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:369)
at com.squareup.otto.Bus.post(Bus.java:338)
at me.vickychijwani.spectre.view.PostListActivity.onCreate(PostListActivity.java:82)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
This occurs in the following scenario: when the app is in the background, the entire process may get killed, but activity back stack is maintained. So when the app is re-opened, Application#onCreate() is called again, which re-initializes the NetworkService, which sets mApi (and mAuthToken!) to null, which causes the NPE above.
vickychijwani
changed the title
NullPointerException in NetworkService.java line 99
Crash: NullPointerException in NetworkService.java line 99
May 15, 2015
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Crashlytics issue
The text was updated successfully, but these errors were encountered: