Installation

Installation Guide

Complete installation guide for the Kasookoo Android SDK, from package installation to push notification setup.


Table of Contents

  1. System Requirements
  2. SDK Installation
  3. Project Configuration
  4. Firebase Setup (for Push Notifications)
  5. ProGuard / R8 Configuration
  6. Verify Installation

System Requirements

Development Environment

ComponentMinimumRecommended
Android StudioHedgehog (2023.1.1)Latest stable
Gradle8.08.4+
Kotlin1.9.02.0+
JDK1717+

Target Environment

ComponentMinimumRecommended
Android API24 (Android 7.0 Nougat)33+ (Android 13+)
DevicesAny Android 7.0+ deviceModern devices

Account Requirements

  • ✅ Kasookoo account with publishable key — sign up at kasookoo.ai
  • ✅ Firebase account (free) — required for push notifications
  • ✅ Google Play Console (optional, only for production release)

SDK Installation

Method 1: Maven Repository (Recommended)

Step 1: Add Maven Repository

In settings.gradle.kts (Project level):

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("https://maven.kasookoo.ai/releases")
        }
    }
}

For Groovy DSL (settings.gradle):

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://maven.kasookoo.ai/releases'
        }
    }
}

Step 2: Add Dependency

In app/build.gradle.kts:

dependencies {
    implementation("com.kasookoo:sdk-android:1.0.0")
    
    // Required if not already added
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
    implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
}

Step 3: Sync Project

Click "Sync Now" when Android Studio prompts.

Method 2: AAR File (Manual)

For offline or restricted environments:

  1. Download kasookoo-sdk-1.0.0.aar from your Kasookoo dashboard
  2. Create libs/ folder in your app module
  3. Copy the AAR file there
  4. In app/build.gradle.kts:
dependencies {
    implementation(files("libs/kasookoo-sdk-1.0.0.aar"))
}

Project Configuration

1. Update build.gradle.kts (App)

Configure compile and target SDK:

android {
    namespace = "com.yourcompany.yourapp"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.yourcompany.yourapp"
        minSdk = 24
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildFeatures {
        viewBinding = true
        // For Jetpack Compose:
        // compose = true
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }
}

2. Add Permissions to AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Network -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

    <!-- Audio -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

    <!-- Bluetooth (for headphones) -->
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

    <!-- Telecom for ConnectionService -->
    <uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <!-- Foreground service for calls -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <!-- Push notifications -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- Hardware features -->
    <uses-feature
        android:name="android.hardware.microphone"
        android:required="true" />

    <application
        android:name=".MyApplication"
        ...>

        <!-- Kasookoo's ConnectionService (auto-registered by SDK) -->
        <service
            android:name="com.kasookoo.sdk.telecom.KasookooConnectionService"
            android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
            android:exported="true">
            <intent-filter>
                <action android:name="android.telecom.ConnectionService" />
            </intent-filter>
        </service>
    </application>
</manifest>

3. Application Class Setup

Create or update your Application class:

package com.yourcompany.yourapp

import android.app.Application
import com.kasookoo.sdk.KasookooSDK
import com.kasookoo.sdk.KasookooConfig
import com.kasookoo.sdk.Environment

class MyApplication : Application() {

    lateinit var sdk: KasookooSDK
        private set

    override fun onCreate() {
        super.onCreate()
        
        // Initialize SDK instance (lightweight, doesn't connect)
        sdk = KasookooSDK(this)
        
        // Initialize with config
        val config = KasookooConfig(
            publishableKey = BuildConfig.KASOOKOO_PUBLISHABLE_KEY,
            organizationId = "your_org_id",
            environment = if (BuildConfig.DEBUG) {
                Environment.SANDBOX
            } else {
                Environment.PRODUCTION
            }
        )
        
        kotlinx.coroutines.runBlocking {
            sdk.initialize(config)
        }
    }
}

4. Store Publishable Key Securely

In local.properties (NOT in version control):

KASOOKOO_PUBLISHABLE_KEY=pk_test_YOUR_KEY_HERE

In app/build.gradle.kts:

android {
    defaultConfig {
        // Read from local.properties
        val localProps = gradleLocalProperties(rootDir, providers)
        buildConfigField(
            type = "String",
            name = "KASOOKOO_PUBLISHABLE_KEY",
            value = "\"${localProps.getProperty("KASOOKOO_PUBLISHABLE_KEY")}\""
        )
    }
    
    buildFeatures {
        buildConfig = true
    }
}

Firebase Setup (for Push Notifications)

Note: If you're using Kasookoo's hosted Firebase project, skip this section and use the google-services.json provided during onboarding.

1. Create a Firebase Project

  1. Go to Firebase Console
  2. Click Add project
  3. Enter project name (e.g., "MyApp-Android")
  4. Disable Google Analytics for now (you can enable later)
  5. Click Create project

2. Add Android App to Firebase

  1. In Firebase project dashboard, click Android icon
  2. Fill in:
    • Android package name: Same as your applicationId (e.g., com.yourcompany.yourapp)
    • App nickname: "MyApp Android"
    • Debug signing certificate SHA-1: Get from Android Studio:
      • Open Gradle panel (right side)
      • Navigate to: app → Tasks → android → signingReport
      • Run it and copy SHA1 value
  3. Click Register app

3. Download google-services.json

  1. Click Download google-services.json
  2. Move this file to your app/ folder:
    YourProject/
    └── app/
        ├── build.gradle.kts
        ├── google-services.json   ← Place here
        └── src/...

4. Add Google Services Plugin

In project-level build.gradle.kts:

plugins {
    id("com.google.gms.google-services") version "4.4.0" apply false
}

In app/build.gradle.kts (top of file):

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("com.google.gms.google-services")  // Add this
}

5. Add Firebase Dependencies

In app/build.gradle.kts:

dependencies {
    // Import the Firebase BoM
    implementation(platform("com.google.firebase:firebase-bom:32.7.0"))

    // Add Firebase Cloud Messaging (no version needed)
    implementation("com.google.firebase:firebase-messaging-ktx")
}

6. Create FCM Service

Create MyFirebaseMessagingService.kt:

package com.yourcompany.yourapp

import android.util.Log
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class MyFirebaseMessagingService : FirebaseMessagingService() {

    override fun onNewToken(token: String) {
        super.onNewToken(token)
        Log.d("FCM", "New token: $token")
        
        // Send token to Kasookoo SDK
        CoroutineScope(Dispatchers.IO).launch {
            try {
                val sdk = (application as MyApplication).sdk
                sdk.notifications.registerDevice(
                    fcmToken = token,
                    userType = ParticipantType.CUSTOMER
                )
            } catch (e: Exception) {
                Log.e("FCM", "Token registration failed", e)
            }
        }
    }

    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
        Log.d("FCM", "Message received: ${remoteMessage.data}")
        
        // Forward to SDK for handling (CallKit-style UI, etc.)
        CoroutineScope(Dispatchers.IO).launch {
            try {
                val sdk = (application as MyApplication).sdk
                sdk.notifications.handlePush(payload = remoteMessage.data)
            } catch (e: Exception) {
                Log.e("FCM", "Push handling failed", e)
            }
        }
    }
}

7. Register Service in Manifest

Add inside <application> tag:

<service
    android:name=".MyFirebaseMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

ProGuard / R8 Configuration

If you use code shrinking (ProGuard/R8), add these rules to proguard-rules.pro:

# Kasookoo SDK
-keep class com.kasookoo.sdk.** { *; }
-keep interface com.kasookoo.sdk.** { *; }
-dontwarn com.kasookoo.sdk.**

# LiveKit
-keep class io.livekit.android.** { *; }
-keep interface io.livekit.android.** { *; }
-dontwarn io.livekit.android.**

# WebRTC
-keep class org.webrtc.** { *; }
-keep interface org.webrtc.** { *; }
-dontwarn org.webrtc.**

# OkHttp / Retrofit
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-keep class retrofit2.** { *; }
-keep interface retrofit2.** { *; }

# Kotlinx Serialization
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt
-keep,includedescriptorclasses class com.kasookoo.sdk.**$$serializer { *; }
-keepclassmembers class com.kasookoo.sdk.** {
    *** Companion;
}
-keepclasseswithmembers class com.kasookoo.sdk.** {
    kotlinx.serialization.KSerializer serializer(...);
}

Verify Installation

1. Build the Project

In Android Studio:

  • Build → Clean Project
  • Build → Rebuild Project

You should see: BUILD SUCCESSFUL ✅

2. Test SDK Import

Create a test file or use existing one:

import com.kasookoo.sdk.KasookooSDK

class TestActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val sdk = (application as MyApplication).sdk
        Log.d("Test", "SDK loaded: $sdk")
    }
}

If this compiles, the SDK is correctly installed.

3. Run on Device/Emulator

  1. Connect device via USB (with USB debugging enabled) or start emulator
  2. Click Run ▶️
  3. App should launch without errors

4. Check Logs

After launching the app, you should see in Logcat:

D/SDK: ✅ SDK Initialized
D/FCM: New token: ...

If FCM token is received, Firebase is correctly configured.


Troubleshooting Installation

"Could not find com.kasookoo:sdk-android"

Solutions:

  1. Verify Maven repository added in settings.gradle.kts
  2. Sync Project with Gradle Files (toolbar refresh icon)
  3. File → Invalidate Caches & Restart

"Manifest merger failed"

Cause: Conflicting permissions or services.

Solution: Check AndroidManifest.xml for duplicates.

"google-services.json missing"

Cause: File not in app/ folder.

Solution: Verify file is at app/google-services.json (not project root).

"Default FirebaseApp is not initialized"

Cause: Plugin not applied.

Solution: Verify id("com.google.gms.google-services") in app/build.gradle.kts.

Build error: "java.lang.NoClassDefFoundError"

Cause: ProGuard removing SDK classes.

Solution: Add ProGuard rules above to proguard-rules.pro.


Next Steps

✅ Installation complete? Continue with:


Need Help?



Did this page help you?