1. Add the dependency

Add the package to your app module dependencies.

dependencies {
    implementation("ir.ashkarhq:ashkar-kotlin:0.1.0")
}

2. Connect Ashkar to your app

Create the client when the app starts and install the uncaught exception handler.

import android.app.Application
import ir.ashkarhq.sdk.AshkarClient
import ir.ashkarhq.sdk.AshkarConfig
import ir.ashkarhq.sdk.addAndroidContext
import ir.ashkarhq.sdk.installUncaughtExceptionHandler

class App : Application() {
    lateinit var ashkar: AshkarClient
        private set

    override fun onCreate() {
        super.onCreate()
        ashkar = AshkarClient(
            AshkarConfig(
                projectKey = BuildConfig.ASHKAR_PROJECT_KEY,
                endpoint = "https://app.ashkarhq.ir",
                environment = "production",
                release = "android@1.0.0",
            ),
        )
        ashkar.addAndroidContext(applicationContext)
        ashkar.installUncaughtExceptionHandler()
    }
}

3. Send a test error

Send a test message and allow a short moment for delivery.

import ir.ashkarhq.sdk.AshkarClient
import kotlin.time.Duration.Companion.seconds

fun sendAshkarTest(ashkar: AshkarClient) {
    val eventId = ashkar.captureMessage("Ashkar Android test")
    check(ashkar.flush(2.seconds)) {
        "Ashkar test event was not sent"
    }
    println(eventId)
}

4. Check the result in Issues

Look for “Ashkar Android test” in the project. Uncaught app failures will now be captured automatically.