> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pesapay.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Android

> Install the zkTLS SDK from Maven Central and run a proving session.

## Requirements

Android 7.0 (API 24) or later, compileSdk 36, Kotlin 2.1 or later. The library supports 16 KB memory pages.

## Install

```kotlin build.gradle.kts theme={null}
dependencies {
    implementation("io.github.cr3dentials:zktls-sdk:1.0.0")
}
```

`mavenCentral()` is in Android projects by default. Minification needs nothing from you: the library's consumer rules keep what the core loads.

## Configuration

`SessionConfig` has the same fields as on iOS. See [the configuration table](/zktls-sdk/ios#build-the-configuration).

## Run a session

```kotlin theme={null}
import ai.zktls.sdk.*
import android.app.Activity
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch

class ProveActivity : Activity() {
    private val scope = MainScope()
    private var client: ZktlsClient? = null

    fun prove(config: SessionConfig) {
        if (client != null) return                                   // one session at a time
        val client = ZktlsClient(config).also { this.client = it }
        val lifecycle = ZkTlsLifecycle(this, client.lifecycleHandle)
        client.onProgress { phase, percent -> runOnUiThread { /* update progress */ } }
        scope.launch {
            try {
                client.login(WebViewLoginPresenter(this@ProveActivity))
                try {
                    ZkTlsSessionService.start(this@ProveActivity, lifecycle) { client.cancel() }
                } catch (e: IllegalStateException) {
                    // API 31+: the login finished while the app was in the background.
                }
                lifecycle.begin()
                client.capture()
                val report = client.prove()
                if (!report.accepted) return@launch show("Not proven: ${report.verdict}")
                val claim = client.claim()                   // verified against the trust bundle
                send(claim.encoded)                          // your backend verifies it again
            } catch (e: SdkException) {
                show(message(e))                             // never retry automatically
            } catch (e: CancellationException) {
                throw e
            } catch (e: Exception) {
                show("Something went wrong. Please try again.")
            } finally {
                lifecycle.end()
                ZkTlsSessionService.stop(this@ProveActivity)
                this@ProveActivity.client = null
            }
        }
    }

    fun cancelTapped() { client?.cancel() }

    override fun onDestroy() {
        scope.cancel()
        super.onDestroy()
    }
}
```

## Things to know

* **The foreground service** is a `shortService`. Start it only after `login` returns and stop it on every path. From API 31 Android refuses to start it while your app is in the background, which is why the snippet catches the exception. Android ends it after about three minutes.
* **One session at a time.** `ZkTlsSessionService` holds one session. Guard as the snippet does.
* **Shared WebView state.** `CookieManager`, web storage and the WebView cache are process-wide. The login clears all three before and after, so do not run a login while your own WebView data matters.
* **The notification** reads "Verifying" in a channel named "Verification". Override `zktls_session_notification_title`, `zktls_session_channel_name` and the drawable `zktls_session_notification_icon` to translate or rebrand it.
* **Error text.** `SdkException.Transport` and `.Policy` carry their text in `e.v1`. Match and log `e.v1`, not `e.message`.
* **Other exceptions.** A fault inside the SDK that is not an `SdkException` arrives as `InternalException`. Catch it and report it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.