Getting crash almost all the time

Hi, everybody.
Started integrating the Sendbird android UIKit and faced with the following crash.
When I send message to some user, then go back to ChannelsListFragment and then enter to the chat(ChannelFragment) I previously was, app always crashes.

This is the error I am getting:

        at java.util.TreeMap.key(
        at java.util.TreeMap.firstKey(
        at java.util.TreeSet.first(
        at com.sendbird.uikit.model.MessageList.getLatestMessage(
        at com.sendbird.uikit.vm.ChannelViewModel.getLatestMessage(
        at com.sendbird.uikit.fragments.ChannelFragment.lambda$null$9$com-sendbird-uikit-fragments-ChannelFragment(
        at com.sendbird.uikit.fragments.ChannelFragment$$ExternalSyntheticLambda23.onListUpdated(Unknown Source:11)
        at com.sendbird.uikit.activities.adapter.MessageListAdapter.lambda$null$5$com-sendbird-uikit-activities-adapter-MessageListAdapter(
        at com.sendbird.uikit.activities.adapter.MessageListAdapter$$ Source:14)

Hi, Could you let me know the version of our chat SDK and UIKit SDK?

I use this dependency:
implementation ‘com.sendbird.sdk:uikit:2.2.1’

Inside ChannelViewModel, SDK asks for latest messages, but list is empty.
Because of the fact, that you use “first” method, the app getting crashed all the time

Do you use Chat SDK? only UIKit SDK?

  • Did you customize ChannelFragment?

I use UIKit SDK and yes I customized a bit ChannelFragment

How did you customize it?

return Builder(ChatChannelFragmentArgs.fromBundle(args).keyChannelUrl)
                .setMessageListAdapter(AlikeMessageListAdapter(avatarBitmapHelper) { view, userId ->
                    view.findNavController().navigate(MainNavigationDirections.actionGlobalToProfileFragment(userId, fromChat = true))
                .also {

I am trying to reproduce your issue. I cannot reproduce it…! :frowning:
However, we add protection codes for this issue. It will be released this week.
I will notice you when fixed version is released.

  • If possible, Could you let me know reproduceable steps in detail?

Hi @Vladislav_Karpman
UIKit v2.2.2 was released! Please use this version and check whether this issue is solved!

It happens because inside method loadInitial in ChannelViewModel, you firstly clear cachedMessages and then waiting for response from BE.

But method adapter.setItems inside ChannelFragment is called before onCacheResult is called.
That’s why cachedMessages is empty.
You simply didn’t handle this scenario, but you should since everything happens asynchronically!

And I’ve recently found a new issue.
Should I report here ?
Or I will need to create a new topic?

@Vladislav_Karpman Please report a new issue to UIKit board.