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

Fatal Exception: java.lang.AssertionError: Crisp ChatBox SDK has not been configured yet. Please make sure to call Crisp.configure(String websiteID) first! #182

Open nfonjeannoel opened 1 month ago

nfonjeannoel commented 1 month ago

I have been getting a few crash logs from firebase analytics. I have not been able to reproduce this crash, so don't know what is causing the crash. Yes I have Crisp.configure(this, BuildConfig.CRISP_WEBSITE_ID) in my launch activity.

Fatal Exception: java.lang.AssertionError Crisp ChatBox SDK has not been configured yet. Please make sure to call Crisp.configure(String websiteID) first!

full crash logs Fatal Exception: java.lang.AssertionError: Crisp ChatBox SDK has not been configured yet. Please make sure to call Crisp.configure(String websiteID) first! at org.junit.Assert.fail(Assert.java:89) at org.junit.Assert.assertTrue(Assert.java:42) at org.junit.Assert.assertNotNull(Assert.java:713) at im.crisp.client.ChatActivity.onCreate(SourceFile:70) at android.app.Activity.performCreate(Activity.java:8547) at android.app.Activity.performCreate(Activity.java:8511) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1437) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3877) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4042) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2436) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:211) at android.os.Looper.loop(Looper.java:300) at android.app.ActivityThread.main(ActivityThread.java:8324) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:581) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)

My thoughts. Must Crisp.configure be called in the same activity that host the fragment where crisp chat needs to be configured?

presently, I can Crisp.configure( in a activity called when the app launches but I instantiate Crisp chat in the activity that hosts the chat. Could this be the issue? can't test because I have actually not been able to reproduce this crash, but I see if from firebase analytics.

jom16antonio commented 3 weeks ago

It would be better to put the configuration function call in your Application class.

Doc1faux commented 3 weeks ago

Hi @nfonjeannoel thank you for your feedback and sorry for my late reply...

What version of the SDK are you using? Since v1.0.14, the SDK should just silently fail, close the ChatActivity and log the AssertionError you have instead of throwing it.

Crisp.configure should at least be called once per App Lifecycle before launching the ChatActivity no matter where you do it, calling it from the Application.onCreate() method is just a convenient way to ensure it is set at the beginning of the App Lifecycle if you use only one website.

Hope this could help you :)

nfonjeannoel commented 2 weeks ago

Using v1.0.13 @Doc1faux Thank you. WIll update to latest version then