Skip to main content
FieldValue
Packagecom.cometchat:chat-uikit-android v5.x
InitCometChatUIKit.init(context, UIKitSettings, callback) — must resolve before login()
LoginCometChatUIKit.login("UID", callback) — must resolve before rendering components
Orderinit()login() → render. Breaking this order = blank screen
Auth KeyDev/testing only. Use Auth Token in production
ThemeSet CometChatTheme.DayNight as parent theme in themes.xml
CallingOptional. Add com.cometchat:calls-sdk-android to enable voice/video
Min SDKAndroid 7.0 (API 24)
This guide walks you through adding CometChat to an Android app. By the end you’ll have a working chat UI.

Prerequisites

You need three things from the CometChat Dashboard:
CredentialWhere to find it
App IDDashboard → Your App → Credentials
Auth KeyDashboard → Your App → Credentials
RegionDashboard → Your App → Credentials (e.g. us, eu, in)
You also need:
  • Android Studio installed
  • An Android emulator or physical device running Android 7.0 (API 24) or higher
  • Java 8 or higher
  • Gradle plugin 4.0.1 or later
Auth Key is for development only. In production, generate Auth Tokens server-side via the REST API and use loginWithAuthToken(). Never ship Auth Keys in client code.

Step 1 — Create an Android Project

  1. Open Android Studio and start a new project.
  2. Choose Empty Activity as the project template.
  3. Enter a project name and choose Java or Kotlin as the language.
  4. Set minimum API level to 24 or higher.

Step 2 — Install Dependencies

Add the CometChat repository and dependencies to your Gradle configuration.

Add the CometChat Repository

Add the CometChat Maven repository to your project-level settings.gradle or settings.gradle.kts file.
settings.gradle.kts
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven("https://dl.cloudsmith.io/public/cometchat/cometchat/maven/")
    }
}

Add the CometChat Dependency

Inside libs.versions.toml, add the CometChat Chat UI Kit version under the [versions] section:
libs.versions.toml
[versions]
cometchat-ui-kit = "5.2.9"
cometchat-calls-sdk = "4.3.3"
Under the [libraries] section, define the library and reference the version:
libs.versions.toml
[libraries]
cometchat-ui-kit = { module = "com.cometchat:chat-uikit-android", version.ref = "cometchat-ui-kit" }
cometchat-calls-sdk = { module = "com.cometchat:calls-sdk-android", version.ref = "cometchat-calls-sdk" }
Now, in your app-level build.gradle.kts file, add the dependency using libs from Version Catalogs:
build.gradle.kts
dependencies {
    implementation(libs.cometchat.ui.kit)

    // (Optional) Include if using voice/video calling features
    implementation(libs.cometchat.calls.sdk)
}

Add AndroidX Support

The Jetifier tool helps migrate legacy support libraries to AndroidX. Open gradle.properties and verify this line is present:
gradle.properties
android.enableJetifier=true

Step 3 — Initialize and Login

To authenticate a user, you need a UID. You can either create users on the CometChat Dashboard, via the SDK method, or through the REST API. For development, use one of the pre-created test UIDs: cometchat-uid-1 · cometchat-uid-2 · cometchat-uid-3 · cometchat-uid-4 · cometchat-uid-5
MainActivity.kt
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.enableEdgeToEdge
import com.cometchat.chat.core.CometChat
import com.cometchat.chat.exceptions.CometChatException
import com.cometchat.chat.models.User
import com.cometchat.chatuikit.shared.cometchatuikit.CometChatUIKit
import com.cometchat.chatuikit.shared.cometchatuikit.UIKitSettings

class MainActivity : ComponentActivity() {

    private val TAG = "MainActivity"

    private val appID = "APP_ID" // Replace with your App ID
    private val region = "REGION" // Replace with your App Region
    private val authKey = "AUTH_KEY" // Replace with your Auth Key or leave blank if you are authenticating using Auth Token

    private val uiKitSettings = UIKitSettings.UIKitSettingsBuilder()
        .setRegion(region)
        .setAppId(appID)
        .setAuthKey(authKey)
        .subscribePresenceForAllUsers()
        .build()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()

        CometChatUIKit.init(this, uiKitSettings, object : CometChat.CallbackListener<String?>() {
            override fun onSuccess(successString: String?) {

                Log.d(TAG, "Initialization completed successfully")

                loginUser()
            }

            override fun onError(e: CometChatException?) {}
        })
    }

    private fun loginUser() {
        CometChatUIKit.login("cometchat-uid-1", object : CometChat.CallbackListener<User>() {
            override fun onSuccess(user: User) {

                // Option 1: Launch One-to-One or Group Chat Screen
                // val intent = Intent(this@MainActivity, MessageActivity::class.java)
                // intent.putExtra("uid", "cometchat-uid-1")
                // startActivity(intent)

                // Option 2: Launch Conversation List + Message View (Split-Screen Style)
                // startActivity(Intent(this@MainActivity, ConversationActivity::class.java))

                // Option 3: Launch Tab-Based Chat Experience (Chats, Calls, Users, Groups)
                // startActivity(Intent(this@MainActivity, TabbedActivity::class.java))
            }

            override fun onError(e: CometChatException) {
                // Handle login failure (e.g. show error message or retry)
                Log.e("Login", "Login failed: ${e.message}")
            }
        })
    }
}
init() must resolve before you call login(). If you call login() before init completes, it will fail silently.
For production, use loginWithAuthToken() instead of Auth Key. Generate tokens server-side via the REST API.

Step 4 — Set Up Global Theme

To customize component styling across your application, set up the CometChat Theme. Use the CometChatTheme.DayNight style, which is built on Theme.MaterialComponents.DayNight.NoActionBar.
themes.xml
<style name="YourAppParentTheme" parent="CometChatTheme.DayNight"/>
AndroidManifest.xml
<application
  android:theme="@style/YourAppParentTheme"
    ...
    ...
  >

</application>

Step 5 — Choose a Chat Experience

Integrate a conversation view that suits your app’s UX. Each option below includes a description and a step-by-step guide.

Conversation List + Message View

Single-screen layout for mobile — tap a conversation to open the message view. Handles one-to-one and group conversations with real-time updates and session persistence.

Build Conversation List + Message View

Step-by-step guide to build this layout

One-to-One / Group Chat

Single chat window — no sidebar. Loads a specific user or group chat directly. Ideal for support chat, direct messages, or notification-driven flows.

Build One-to-One / Group Chat

Step-by-step guide to build this layout

Tab-Based Chat

Bottom navigation with tabs for Chats, Calls, Users, and Settings. Mobile-first, modular, and extensible for multi-feature apps.

Build Tab-Based Chat

Step-by-step guide to build this layout

Build Your Own Chat Experience

Need full control over the UI? Use individual components, customize themes, and wire up your own layouts.

Next Steps