crisp-im / crisp-sdk-android

:package: Crisp Android SDK, add a chat in any Android app and communicate with your users.
https://docs.crisp.chat/guides/chatbox-sdks/android-sdk/
Other
55 stars 17 forks source link

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.gson.JsonPrimitive.getAsString()' on a null object reference #43

Closed FrantisekGazo closed 3 years ago

FrantisekGazo commented 3 years ago

I'm encountering crashes when I use token id -> see logs: logs.txt

When I start our app 1st time, set token id and start chat everything works. But when I close and open chat I get a crash. And then every time I try to open a chat I get the same crash. That is until I reset session and use a different token ID. (but the crash shows again after a while and I have to use a new id again...)

There's nothing I can do on my side, can you help?

FrantisekGazo commented 3 years ago

I just discovered that the issue happens even when I don't set the token id.

After closing and opening a chat few time I see the same crash mentioned before. And after restarting our app the sdk crashes on Crisp.configure(...) call.

E/MethodChannel#com.ventrata/intercom(28671): Failed to handle method call
E/MethodChannel#com.ventrata/intercom(28671): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.gson.JsonPrimitive.getAsString()' on a null object reference
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.b.d.e.k.a(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.b.d.e.k.deserialize(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
E/MethodChannel#com.ventrata/intercom(28671):   at com.google.gson.Gson.fromJson(Gson.java:927)
E/MethodChannel#com.ventrata/intercom(28671):   at com.google.gson.Gson.fromJson(Gson.java:892)
E/MethodChannel#com.ventrata/intercom(28671):   at com.google.gson.Gson.fromJson(Gson.java:841)
E/MethodChannel#com.ventrata/intercom(28671):   at com.google.gson.Gson.fromJson(Gson.java:813)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.b.b.b.readObject(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.ventrata/intercom(28671):   at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1006)
E/MethodChannel#com.ventrata/intercom(28671):   at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1894)
E/MethodChannel#com.ventrata/intercom(28671):   at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1799)
E/MethodChannel#com.ventrata/intercom(28671):   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
E/MethodChannel#com.ventrata/intercom(28671):   at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.b.a.a.e(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.b.a.a.k(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.b.a.a.j(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.b.a.a.<init>(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.b.a.a.a(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.Crisp.resetChatSession(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at im.crisp.client.Crisp.configure(SourceFile)
E/MethodChannel#com.ventrata/intercom(28671):   at com.ventrata.intercom.plugin.IntercomPluginMethodHandler.setup(IntercomPlugin.kt:85)
E/MethodChannel#com.ventrata/intercom(28671):   at com.ventrata.intercom.plugin.IntercomPluginMethodHandler.onMethodCall(IntercomPlugin.kt:62)
E/MethodChannel#com.ventrata/intercom(28671):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#com.ventrata/intercom(28671):   at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#com.ventrata/intercom(28671):   at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/MethodChannel#com.ventrata/intercom(28671):   at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.ventrata/intercom(28671):   at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#com.ventrata/intercom(28671):   at android.os.Looper.loop(Looper.java:136)
E/MethodChannel#com.ventrata/intercom(28671):   at android.app.ActivityThread.main(ActivityThread.java:6077)
E/MethodChannel#com.ventrata/intercom(28671):   at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.ventrata/intercom(28671):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
E/MethodChannel#com.ventrata/intercom(28671):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
ollym commented 3 years ago

hey @baptistejamin this is blocking a fairly major move we want to transition all our apps to Crisp. Is there any incentive we can offer to have this fixed this week?

FrantisekGazo commented 3 years ago

hi, any update on this?

baptistejamin commented 3 years ago

It happens only when using the Token_ID?

FrantisekGazo commented 3 years ago

no, I also tried it without the token id

FrantisekGazo commented 3 years ago

I only set these

Crisp.setUserNickname(user.name)
Crisp.setUserEmail(user.email)
if (user.phone != null) {
    Crisp.setUserPhone(user.phone)
}
if (user.company != null) {
    Crisp.setUserCompany(Company(user.company, null, null, null, null))
}

(our user name and email is always non-null)

And when I open chat, write a single message and then close chat and repeat this 3-times I get that crash when opening the chat for the 4rd time. After that I get a crash everytime I start app and run Crisp.configure(context, config.key) (I don't even get to opening the chat)

alimcharaniya commented 3 years ago

Facing the same issue currently.

eliottvincent commented 3 years ago

We just released a new version (1.0.3), it should fix the issue. Could you please give it a try and confirm?

FrantisekGazo commented 3 years ago

yes, 1.0.3 is working Thanks :)

eliottvincent commented 3 years ago

Great news! Closing the issue then :)

wahyuabid commented 3 years ago

Hi guys i still get this issue (in 1.0.3) after i send/attach an image in chat. can you help to solve this problem ? please @baptistejamin