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

# Installation

> Add the Video SDK to your Android project, initialize it at launch, and see what it adds to your manifest.

> [!NOTE]
>
> You'll need a [publisher account](https://docs.kontext.so/publishers.md#getting-started-is-easy) to obtain your `publisherToken`.

## 1. Add the SDK

The SDK is on Maven Central. Make sure `mavenCentral()` is in your repositories, then add the dependency to your app module's `build.gradle.kts`:

```kotlin theme={null}
dependencies {
    implementation("so.kontext:video:0.1.0")
    implementation("so.kontext:video-media3:0.1.0")   // optional: ads.track(exoPlayer)
    implementation("so.kontext:video-ttsdk:0.1.0")    // optional: ads.track(ttVideoEngine)
    implementation("so.kontext:video-txplayer:0.1.0") // optional: ads.track(txVodPlayer)
    implementation("so.kontext:video-compose:0.1.0")  // optional: Jetpack Compose
}
```

`video-media3` is the adapter for a [Media3](https://developer.android.com/media/media3) player (`ExoPlayer`, `MediaController`). Add it when your content plays in one; your app's own Media3 version is used. `video-ttsdk` is the adapter for a TTSDK player (`TTVideoEngine`, 1.40 or later); it uses your app's own, licensed TTSDK. `video-txplayer` is the adapter for a [Tencent Cloud Player](https://docs.kontext.so/video/sdk/kotlin/txplayer.md) SDK player (`TXVodPlayer`, 11.0 or later); it uses your app's own, licensed Player SDK. `video-compose` adds `rememberVideoAds` and `VideoAdHost` for [Jetpack Compose](https://docs.kontext.so/video/sdk/kotlin/compose.md). Pin an exact version: while the SDK is below 1.0, a new minor version can change the API, so you move to it when you choose.

> [!NOTE]
>
> The SDK depends on [KontextKit](https://github.com/kontextso/kontextkit-android), shared Android primitives (install id, device info, advertising id, consent). Gradle pulls it in for you. Neither needs R8 rules from you: the SDK ships its own consumer rules.

## 2. Initialize at launch

Call `initialize` once, in your `Application.onCreate`. It stores the configuration and calls the server in the background; nothing waits on it.

```kotlin theme={null}
import so.kontext.video.KontextVideo.Configuration
import so.kontext.video.KontextVideo

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        KontextVideo.initialize(this, Configuration("<your-publisher-token>"))
    }
}
```

Register the class in your manifest with `<application android:name=".App" …>`. To hear the result, pass a listener, or call `awaitInitialization()` from a coroutine:

```kotlin theme={null}
KontextVideo.initialize(this, Configuration("<your-publisher-token>")) { state -> … }

val state = KontextVideo.awaitInitialization()
```

A second call is ignored. Every ads request made before initialization finishes simply waits for it, so you can create a `VideoAds` right away.

> [!NOTE]
>
> Call `KontextVideo`, `VideoAds` and `VideoAd` from the main thread, the default in Activities, Fragments, Compose and `lifecycleScope`. Only `format()`, `load()` and `awaitInitialization()` may be called from any dispatcher: they switch to the main thread. Called from another thread, any other call stops a debuggable build and does nothing in a release build (`show` throws `CannotShowNow`). Listeners and callbacks are delivered on the main thread too.

### Configuration

```kotlin theme={null}
Configuration("<your-publisher-token>") {
    logLevel = Configuration.LogLevel.WARNING   // NONE, ERROR, WARNING, INFO, DEBUG
}
```

Use `LogLevel.DEBUG` while integrating; it logs every request, every ad and every beacon to Logcat under the tag `KontextVideo` (`adb logcat -s KontextVideo`).

## 3. What the SDK adds to your manifest

Nothing to configure: manifest merger adds these for you.

* `INTERNET` and `ACCESS_NETWORK_STATE`, for the ads requests and the connection type.
* `com.google.android.gms.permission.AD_ID`, so the SDK can read the advertising id on Android 13 and later. There is no runtime prompt; the SDK reads the id from Google Play services and sends none when the viewer opted out. See [IFA & ATT](https://docs.kontext.so/video/guides/ifa.md#android-gaid).
* The SDK's own Activity for linear ads.

### Removing AD\_ID (kids apps)

Google Play does not allow apps for children to declare `AD_ID`. Remove it in your app's `AndroidManifest.xml`:

```xml theme={null}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove" />
</manifest>
```

Without it, Google Play services returns no advertising id and the SDK sends none; ads still work. Set `coppa = true` in `regulatory` for a child audience too: the SDK then also leaves out the user id and email. Declare the rest in the [Google Play Data safety](https://docs.kontext.so/video/resources/compliance.md#google-play-data-safety) form.

Android has no App Tracking Transparency and no SKAdNetwork: there is no `Info.plist` step and no attribution identifier to add.


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