Skip to main content
This guide covers the breaking changes in CometChat Android SDK v5 and what you need to update in your app.

Dependency Update

Update your build.gradle dependency:

Breaking Changes Overview

SDK v5 removes the Gson dependency from all SDK model classes and changes equals() / hashCode() to structural (deep) equality. All SDK model classes now implement Parcelable.

Must Do (will crash without these)

Replace Gson deserialization of SDK classes

Gson().fromJson(json, BaseMessage::class.java) no longer works because SDK classes no longer have Gson annotations. Before (v4):
After (v5):
For Conversation: Before (v4):
After (v5): Use Parcelable to pass between components, or reconstruct from the SDK’s fetch methods.

Replace Gson-based Intent/Bundle passing

All SDK model classes (User, Group, BaseMessage, Conversation, etc.) now implement Parcelable. Use putExtra() / IntentCompat.getParcelableExtra() instead of Gson serialization.

User

Before (v4):
After (v5):

BaseMessage

Before (v4):
After (v5):

Group

Before (v4):
After (v5):

Conversation

Before (v4):
After (v5):
This pattern applies to all SDK model classes — Call, Action, MediaMessage, TextMessage, CustomMessage, etc. They all implement Parcelable in v5.

Replace Gson clone hacks

Before (v4):
After (v5):

Must Do (will cause silent bugs without these)

Update DiffUtil comparisons

equals() now does deep structural comparison. Using it in areItemsTheSame() will cause incorrect diff results. Before (v4):
After (v5):

Replace list contains/remove with ID-based operations

Before (v4):
After (v5):

Stop using SDK objects as HashMap/HashSet keys

Before (v4):
After (v5):

Add ProGuard keep rules

Add the following to your proguard-rules.pro:

Should Review

These won’t crash but may cause unexpected behavior if your code relied on the old identity-based equality:
  • Any code that relied on user1.equals(user2) meaning “same user” — it now means “identical in every field”
  • Any code that relied on message1.equals(message2) meaning “same message” — it now means “identical in every field including read receipts, reactions, etc.”
  • Any code comparing Conversations via equals() — now does recursive deep comparison of lastMessage and conversationWith

Safe — No Changes Needed

These patterns continue to work without modification:
  • Gson usage for your own custom DTOs (not SDK classes)
  • User.fromJson(), Group.fromJson(), BaseMessage.processMessage() — these SDK methods still work
  • user.toJson(), group.toMap() — these SDK serialization methods still work