Skip to main content
You’ll need a publisher account 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:
video-media3 is the adapter for a 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 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. 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.
The SDK depends on KontextKit, 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.
Register the class in your manifest with <application android:name=".App" …>. To hear the result, pass a listener, or call awaitInitialization() from a coroutine:
A second call is ignored. Every ads request made before initialization finishes simply waits for it, so you can create a VideoAds right away.
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

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.
  • 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:
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 form. Android has no App Tracking Transparency and no SKAdNetwork: there is no Info.plist step and no attribution identifier to add.