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:24.3.0'
}
精简版 SDK 的局限性
SDK 精简版只能在通过 Google Play 商店分发的应用中使用。
与其他 Google Play 服务不同,Google Play 服务 APK 中的标准 Google 移动广告 SDK 实现也包含在 Google Play 服务客户端库中。这就使得没有 Google Play 服务 APK 的设备也能支持该 SDK。在运行时,该 SDK 会比较客户端库和 Google Play 服务 APK 的版本,并使用较新的版本。
精简版 SDK 会从客户端库中剥离 Google 移动广告 SDK 实现,仅保留 Google Play 服务 APK 的接口。精简版 SDK 依赖于 APK 的实现。如果您在 Google Play 商店之外部署应用,则无法保证用户设备上安装了 Google Play 服务 APK。
在安装了最新版 Google Play 服务的设备上,精简版 SDK 的行为与标准版 SDK 的行为完全相同。不过,在 Google Play 服务过时或不存在的设备上,精简版 SDK 可能会引用 Google Play 服务 APK 中不可用或已更改的 API。这会导致系统执行空操作并记录错误,从而可能导致广告无法投放到这些设备。
精简版 SDK 发布频率
从 24.1.0 版开始,play-services-ads-lite
制品将不再以与 play-services-ads
相同的频率发布。此更改可实现更平稳、更稳定的 SDK 实现推出。
Lite SDK 大约每隔两个 SDK 版本发布一次。
如果项目同时依赖于 play-services-ads-lite
24.0.0 版或更低版本和 play-services-ads
24.1.0 版或更高版本,则在应用编译期间会遇到 Duplicate class
错误。如需解决此错误,请仅使用 play-services-ads
或 play-services-ads-lite
工件。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThe Google Mobile Ads Lite SDK is a smaller version of the Google Mobile Ads SDK, designed to reduce app size and method references.\u003c/p\u003e\n"],["\u003cp\u003eUsing the Lite SDK helps avoid the 64K reference limit, especially beneficial when targeting older Android versions.\u003c/p\u003e\n"],["\u003cp\u003eThe Lite SDK is exclusively for apps distributed via the Google Play Store and relies on the Google Play services APK for its implementation.\u003c/p\u003e\n"],["\u003cp\u003eOn devices lacking or with outdated Google Play services, the Lite SDK may encounter API discrepancies, leading to ad serving issues.\u003c/p\u003e\n"],["\u003cp\u003eWhile 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.\u003c/p\u003e\n"]]],[],null,["Like any Android library, the Google Play services SDK increases the size of\napps that include it. The Google Mobile Ads Lite SDK is a lightweight version\nof the Google Mobile Ads SDK built to reduce that impact. It is a fraction of\nthe size of the regular SDK.\n\nAlongside reduced size, using the Lite SDK decreases the total number of\nmethods referenced in an app. This is especially useful when deploying to older\nversions of Android, where developers can run into the [64K reference\nlimit](//developer.android.com/studio/build/multidex).\n\nHere's how to configure gradle to incorporate the Lite SDK into your app: \n\n dependencies {\n implementation 'com.google.android.gms:play-services-ads-lite:24.3.0'\n }\n\nLimitations of the Lite SDK\n\nThe Lite SDK should only be used in apps distributed through the\nGoogle Play store.\n\nUnlike other [Google Play services](/android/guides/overview), the standard\nGoogle Mobile Ads SDK implementation in the Google Play services APK is also\nincluded in the Google Play services client library. This allows for support on\ndevices without the Google Play services APK. At runtime, the SDK will compare\nthe versions of the client library and the Google Play services APK and use the\nnewer version.\n\nThe Lite SDK strips the Google Mobile Ads SDK implementation from the client\nlibrary, leaving only an interface to the Google Play services APK. The Lite\nSDK relies on the implementation of the APK. If you deploy your app outside of\nthe Google Play store, it is not guaranteed that your user's devices will have\nthe Google Play services APK installed.\n\nOn devices with an up-to-date version of Google Play services, the Lite SDK's\nbehavior is identical to that of the standard SDK. However, on devices where\nGoogle Play services is outdated or not present, the Lite SDK may reference\nAPIs that are unavailable or have been changed from those in the Google Play\nservices APK. This will result in a no-op and an error being logged, which may\ncause ads not to serve to those devices.\n\nLite SDK release cadence\n\nStarting with version 24.1.0, the `play-services-ads-lite`\nartifact stops releasing at the same cadence as `play-services-ads`. This\nchange allows for a more gradual and stable rollout of the SDK implementation.\nThe Lite SDK releases approximately every third SDK release.\n\nProjects that depend on both `play-services-ads-lite` version 24.0.0 or lower\nand `play-services-ads` version 24.1.0 or higher encounter a `Duplicate class`\nerror during app compilation. Resolve this error by using only one of the\n`play-services-ads` or `play-services-ads-lite` artifacts."]]