---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
alternate:
  - https://boost.yandex.com/doc/en/analytics/content/sdk/android/get-ad-id.md
  - https://boost.yandex.com/doc/ru/analytics/content/sdk/android/get-ad-id.md
  - https://boost.yandex.com/doc/zh/analytics/content/sdk/android/get-ad-id.md
  - href: https://boost.yandex.com/doc/zh/analytics/content/sdk/android/get-ad-id.md
    type: text/markdown
    title: Markdown version
  - href: https://boost.yandex.com/doc/zh/llms.txt?revision=r21738064
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.com/doc/zh/llms.txt?revision=r21738064

# 获取广告 ID

广告 ID 是 Google Play 服务的一个唯一标识符，用于向同意查看个性化广告的用户展示广告。 用户可以在设置中禁用广告个性化或重置 ID。 在这种情况下，广告网络无法使用它来选择相关的广告。 流量归属的准确性也会显著下降。

AppMetricaSDK 使用 `io.appmetrica.analytics:analytics-identifiers` 这个独立的库来获取广告 ID。 此库依赖于 `com.google.android.gms:play-services-ads-identifier`，用于获取 GAID。 库 `io.appmetrica.analytics:analytics-identifiers` 的版本应与库 `io.appmetrica.analytics:analytics` 的版本相匹配。

默认添加对 `io.appmetrica.analytics:analytics-identifiers` 库的依赖。

- 如果你打算永不使用广告标识符，[禁用依赖项](#disable)。

- 如果您不想在某些情况下使用广告标识符，或者需要等待用户同意，请通过 [API](https://boost.yandex.com/doc/zh/analytics/content/sdk/android/analytics/android-operations.md#track-adv-identifiers) 进行管理。


## 从依赖项列表中排除广告 ID 库 {#disable}

如果您不想获取广告 ID（例如，对于儿童应用），请在项目的 `build.gradle` 文件中排除库：

{% list tabs %}

- build.gradle.kts

   ```kotlin translate=no
   configurations.configureEach {
       exclude(group = "io.appmetrica.analytics", module = "analytics-identifiers")
   }
   ```

- build.gradle

   ```groovy translate=no
   configurations.configureEach {
       exclude group: 'io.appmetrica.analytics', module: 'analytics-identifiers'
   }
   ```

{% endlist %}

<!-- source: zh/analytics/content/_includes/feedback-button-2.md -->
如果您没有找到所需答案，可以通过反馈表单提交您的问题。 请尽可能详细地描述问题。 如果可能，请附上截图。

<a href="../troubleshooting/feedback-new">
  <span class="button">联系支持</span>
</a>

<a href="../troubleshooting/feedback-docs">
  <span class="button">建议改进文档</span>
</a>
<!-- endsource: zh/analytics/content/_includes/feedback-button-2.md -->
