NullPointerException: core.Client.getState()
I've been getting the following crash randomly whenever I open my app, I started noticing it since I upgraded to v3.5.0. What could be the possible cause and how can I resolve it.
java.lang.NullPointerException: Attempt to invoke virtual method 'com.getstream.sdk.chat.rest.core.ClientState com.getstream.sdk.chat.rest.core.Client.getState()' on a null object reference
at com.getstream.sdk.chat.StreamChat$2.onAnyEvent(StreamChat.java:139)
at com.getstream.sdk.chat.rest.core.ChatEventHandler.dispatchEvent(ChatEventHandler.java:136)
at com.getstream.sdk.chat.rest.core.Client.onWSEvent(Client.java:648)
at com.getstream.sdk.chat.rest.EventHandler.handleMessage(EventHandler.java:19)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
@Chikrix this happens when the application returns from background or it first start?
@andriizhumela mostly when it first starts I think
@Chikrix where you init StreamChat? Maybe you try to use chat without initialization? Please, show your code sample.
I downgraded to 3.4.1 to avoid for now, so not seeing this again for now. I am actually seeing this still, it happens occasionally when I just open my app, but not everytime. I am initialising the stream client in my main activity, the log doesn't show me where this error originates from my code, so it makes it difficult to point out the origin from my code, but I'm initialising the stream client in my MainActivity, and other times in my channel list and detail views in case the stream client is destroyed by the system.
I've had to upgrade due to need for changes in the latest update, and I still have this issue.
This is resolved in the 4.x branch