---
url: https://simpledatalogs.com/docs/quickstarts/android.md
description: >-
  Add simpledatalogs to an Android app with the Kotlin SDK, with launches,
  sessions, crashes and screen views captured by one argument.
---

# Android (Kotlin)

## Install

In your app module's `build.gradle.kts`:

```kotlin
dependencies {
    implementation("com.xkdlabs:simpledatalogs:0.1.0")
}
```

It needs minSdk 21 and adds the `INTERNET` permission for you. Until the library is on Maven Central, build it locally as shown in the [Android SDK](/sdks/android#install) page.

## Add it

```kotlin
import com.xkdlabs.simpledatalogs.Autocapture
import com.xkdlabs.simpledatalogs.SimpleDataLogs

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        SimpleDataLogs.configure(this, ingestKey = "sdl_pub_…", autocapture = Autocapture.ALL)
    }
}

// Anywhere, from any thread:
SimpleDataLogs.track("signup", mapOf("plan" to "pro"))
```

Register `MyApplication` with `android:name` on the `<application>` tag, and ship a public `sdl_pub_` key.

## Send everything, or only what you choose

* **Everything:** `Autocapture.ALL` sends launches, sessions, crashes and screen views.
* **Pick:** `Autocapture.SESSIONS + Autocapture.CRASHES`.
* **Only your own events:** leave `autocapture` out.

Compose destinations and fragments are not activities, so send their screen views yourself:

```kotlin
SimpleDataLogs.trackScreen("Settings")
```

## In the first minute

* `session_start` and `app_launched` (with `is_first_launch`) as soon as the first activity starts.
* A `screen_view` each time an activity resumes.
* After an uncaught exception, `app_crashed` on the next launch.
* Your events within 10 seconds (5 while the app is debuggable), and at once when the app goes to the background.

## Autocapture defaults

| Option | With `Autocapture.ALL` |
|---|---|
| `APP_LAUNCHES` | on |
| `SESSIONS` (30 minutes in the background ends one) | on |
| `CRASHES` (uncaught JVM exceptions) | on |
| `SCREEN_VIEWS` (activity resumed, `screen` = class name) | on |

Native (NDK) crashes and ANRs are not captured. Everything else, including the opt-out and WorkManager, is in the [Android SDK](/sdks/android) reference.
