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
56 stars 17 forks source link

JsonSyntaxException #146

Closed pdprober closed 1 year ago

pdprober commented 1 year ago

android version

android 10

device

Redmi Note 7

SDK version

1.0.13

Log

Fatal Exception: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 1305 path $.l at com.google.gson.Gson.fromJson(Gson.java:61) at com.google.gson.Gson.fromJson(Gson.java:4) at com.google.gson.Gson.fromJson(Gson.java:9) at com.google.gson.Gson.fromJson(Gson.java) at im.crisp.client.internal.h.m.readObject(m.java:10) at java.lang.reflect.Method.invoke(Method.java) at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1066) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2013) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1899) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1412) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427) at im.crisp.client.internal.b.a.q(a.java:30) at im.crisp.client.internal.b.a.(a.java:46) at im.crisp.client.internal.b.a.a(a.java:6) at im.crisp.client.Crisp.configure(Crisp.java:6)

Doc1faux commented 1 year ago

Hi @pdprober and thank you for your feedback.

I dived into this exception and unfortunately, I did not reproduced it :/ What I suspected was 2 fields which have been added in Website settings in 1.0.9 and 1.0.11 but deserializing it produced an InvalidClassException (already handled by the SDK as it is inheriting from IOException) and not a MalformedJsonException... So I assume there was an error while saving it instead but without more info, I cannot find the cause of the crash :/

However, in order to fix it, I now handle JsonParseException while deserializing (MalformedJsonException which is an IOException was encapsulated in it, this is why the SDK was not handling it...). No worries, if the Website settings cannot be read from the cache, it is automatically fetched upon socket connection. I also added Website settings log when this parsing exception occurs to get an insight of what is the cause.

It will be released in the next 1.0.14

Doc1faux commented 1 year ago

@pdprober 1.0.14 which should fix this issue has just been released. It can take a few hours before it will be available. I close the issue.