Google 移动广告 SDK 精简版
与所有 Android 库一样,Google Play 服务 SDK 的集成会导致应用增大。但 Google 移动广告 SDK 精简版不同,它是一种轻量级版本的 Google 移动广告 SDK,目的就是减少这种影响。相比之下,常规 SDK 通常要比它大数倍。
除了规模减小外,使用 SDK 精简版还可减少应用中引用的方法总数。在旧版本的 Android 中进行部署时,这点特别有用,因为此时开发者可能会遇到 64K 引用限制。
以下代码说明如何在您的应用中通过配置 Gradle 实现 SDK 精简版的集成:
dependencies {
implementation 'com.google.android.gms:play-services-ads-lite:23.6.0'
}
SDK 精简版的局限性
SDK 精简版只能在通过 Google Play 商店分发的应用中使用。
与其他 Google Play 服务不同,Google Play 服务 APK 中的标准 Google 移动广告 SDK 实现也包含在 Google Play 服务客户端库中。这就使得没有 Google Play 服务 APK 的设备也能支持该 SDK。在运行时,该 SDK 会比较客户端库和 Google Play 服务 APK 的版本,并使用较新的版本。
Lite SDK 会从客户端库中剥离 Google 移动广告 SDK 实现,只留下一个指向 Google Play 服务 APK 的接口。Lite SDK 依赖于 APK 的实现。如果您在 Google Play 商店之外部署应用,则无法保证用户设备上已安装 Google Play 服务 APK。
在安装了最新版 Google Play 服务的设备上,Lite SDK 的行为与标准 SDK 的行为完全相同。不过,在 Google Play 服务已过时或不存在的设备上,Lite SDK 可能会引用不可用的 API 或与 Google Play 服务 APK 中的 API 不同。这将导致无操作并记录错误,这可能会导致广告无法投放到这些设备。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-08。
[null,null,["最后更新时间 (UTC):2025-02-08。"],[[["The Google Mobile Ads Lite SDK is a smaller version of the Google Mobile Ads SDK, designed to reduce app size and method references."],["Using the Lite SDK helps avoid the 64K reference limit, especially beneficial when targeting older Android versions."],["The Lite SDK is exclusively for apps distributed via the Google Play Store and relies on the Google Play services APK for its implementation."],["On devices lacking or with outdated Google Play services, the Lite SDK may encounter API discrepancies, leading to ad serving issues."],["While functionally similar to the standard SDK on updated devices, the Lite SDK depends on the Google Play services APK, making it unsuitable for deployments outside the Play Store."]]],[]]