Reputation: 21
I have followed Android quickstart conversations project I am facing a crash with following details -
com.twilio.conversations.ListenerException: Exception thrown by a listener. Your application might have a problem in listener implementation. Listeners must never throw uncaught exceptions. See 'Caused by:' below for more details.
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at com.twilio.conversations.internal.RethrowingForwarder$RethrowingProxy.invoke(RethrowingForwarder.java:123)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy10.onSuccess(Unknown Source)
at com.twilio.conversations.internal.CallbackListenerForwarder$1.run(CallbackListenerForwarder.java:34)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
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)
Caused by: java.lang.IllegalStateException: Messages are not available at the moment. Synchronize the conversation first.
at com.twilio.conversations.ConversationImpl.getMessages(ConversationImpl.java:214)
at com.twilio.conversations.ConversationImpl.getLastMessages(ConversationImpl.java:282)
at QuickstartConversationsManager.loadPreviousMessages(QuickstartConversationsManager.java:222)
at QuickstartConversationsManager.access$600(QuickstartConversationsManager.java:43)
at QuickstartConversationsManager$3.onSuccess(QuickstartConversationsManager.java:156)
at QuickstartConversationsManager$3.onSuccess(QuickstartConversationsManager.java:147)
at java.lang.reflect.Method.invoke(Native Method)
at com.twilio.conversations.internal.RethrowingForwarder$RethrowingProxy.invoke(RethrowingForwarder.java:121)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy10.onSuccess(Unknown Source)
at com.twilio.conversations.internal.CallbackListenerForwarder$1.run(CallbackListenerForwarder.java:34)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
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)
Any ideas on what is missing or what is wrong?
Upvotes: 2
Views: 1438
Reputation: 136
I know this has been a while, but I experienced this issue while moving from Twilio Chat to Twilio Conversation. How I fixed it was to wrap the method you are calling in a synchronization Status check.
Caused by: java.lang.IllegalStateException: Messages are not available at the moment. Synchronize the conversation first.
is meaning conversation may be out of sync.
if (conversation?.synchronizationStatus?.isAtLeast(Conversation.SynchronizationStatus.ALL) == true) {
conversation?.setAllMessagesRead { value -> Timber.v("Unread Count:" + value) }
}
Here is twilio documentation about what do if your conversation is out of sync or what to do with the else statement.
https://www.twilio.com/docs/conversations/best-practices-sdk-clients#mobile-sdks-specifics
Upvotes: 3