Kotlin · Android
Kotlin SDK for Android View and Jetpack Compose. Android 6.0+ (API 23).
Platform
| Field | Value |
|---|---|
| platformId | Public ID. Shared by the Kotlin SDK and HTTP API for this app. |
| Production / Test | Set at creation. Test always returns demo ads without billing or accounting events. |
| Frequency and daily cap | Configured on the platform page. Apply to live ads. |
| Android package | Optional restriction. The SDK sends packageName automatically. Does not attest app ownership. |
| placement | Defaults to chat. Register other names in settings. |
Installation
Use sdks/android from the repository. No Maven Central package is published. JDK 17, compileSdk 35.
settings.gradle.kts
include(":sidekick-android")project(":sidekick-android").projectDir = file("../sidekick/sdks/android")
app/build.gradle.kts
dependencies {implementation(project(":sidekick-android"))}
Android View
import com.sidekick.ads.*val client = SidekickClient.create(applicationContext, "plt_example")val adView = SidekickAdView(this)container.addView(adView) // wrap_content heightadView.screenActive = trueadView.onError = { error -> /* Keep the original response. */ }adView.load(client, AdRequest(requestId = "chat-42-message-7",placement = "chat",languageCode = "ru",context = AdContext(question = question, answer = answer),test = true,testFormat = AdFormat.CARD))// On permanent disposal:adView.release()client.close()
Call release() and close() on permanent disposal, not immediately after load(). Do not embed an API key in the app.
Jetpack Compose
val client = remember { SidekickClient.create(context, "plt_example") }var ad by remember { mutableStateOf<MobileAd?>(null) }LaunchedEffect(messageId) {ad = try {client.requestAd(AdRequest(requestId = messageId, test = true))} catch (e: CancellationException) {throw e} catch (e: Exception) {null}}DisposableEffect(client) { onDispose { client.close() } }ad?.let { SidekickAd(client, it, screenActive = screenActive) }
Views and lifecycle
View: ≥50% of the card continuously visible for 1 second, active window and screen, loaded media. SidekickAdView sends /seen automatically. Set screenActive=false when an overlay obscures the card.
Keep requestId stable for one message and placement. Changed content requires a new ID. Cached requests and appearance changes do not fetch another ad. Network errors do not automatically retry ad issuance.