> ## 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.

# 安装

> 把 Kotlin SDK 加入你的 Android 项目，并完成 GAID 配置。

<Note>
  你需要一个 [发布方账号](/publishers#getting-started-is-easy) 来获取 `publisherToken` 与 placement code。
</Note>

## 1. 添加 SDK

SDK 发布在 Maven Central，坐标是 `so.kontext:ads`。先确认你的项目仓库配置里包含 `mavenCentral()`：

```kotlin theme={null}
// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}
```

然后在 app 模块的 `build.gradle.kts` 中加入依赖：

```kotlin theme={null}
dependencies {
    implementation("so.kontext:ads:4.0.3") // 替换为最新的 4.x 版本
}
```

SDK 面向 Android API 26+，使用 JVM 17。如果你的项目 target / JVM 比这低，请先升级。

## 2. Google Advertising ID（GAID）

SDK 会在每次广告请求时自动读取并上送 Google Advertising ID。

`com.google.android.gms.permission.AD_ID` 权限会通过 SDK 的清单贡献自动并入你的 `AndroidManifest.xml`——无需修改清单文件。GAID 属于安装时权限，运行时不会弹窗。

<Note>
  如果你的 app 面向 Android 13+（API 33+），并且在清单的某处对 `AD_ID` 权限显式声明了 `tools:node="remove"`，请移除该覆盖，否则运行时无法访问广告标识符。
</Note>

如果你自己采集 GAID，可以通过 `SessionOptions.advertisingId` 直接传入——这个值会优先于 SDK 的自动收集。
