Google Mobile Ads Lite SDK
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
與任何 Android 程式庫一樣,Google Play 服務 SDK 會增加應用程式的大小。Google Mobile Ads Lite SDK 是 Google Mobile Ads SDK 的輕量版,可減少這類影響。大小僅為一般 SDK 的一小部分。
除了縮減大小,使用 Lite SDK 還能減少應用程式中參照的方法總數。這在部署至舊版 Android 時特別實用,因為開發人員可能會遇到 64K 參照限制。
以下說明如何設定 Gradle,將 Lite SDK 併入應用程式:
dependencies {
implementation 'com.google.android.gms:play-services-ads-lite:24.3.0'
}
Lite SDK 的限制
Lite SDK 只能用於透過 Google Play 商店發布的應用程式。
與其他 Google Play 服務不同,Google Play 服務 APK 中的標準 Google Mobile Ads SDK 實作項目也包含在 Google Play 服務用戶端程式庫中。這項變更可讓裝置支援 Google Play 服務 APK。在執行階段,SDK 會比較用戶端程式庫和 Google Play 服務 APK 的版本,並使用較新版本。
Lite SDK 會從用戶端程式庫中移除 Google Mobile Ads 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 不同)。這會導致無作業,並記錄錯誤,可能導致廣告無法放送至這些裝置。
Lite 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
構件。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間: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\u003eIt is ideal for older Android versions, helping avoid the 64K reference limit.\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 on user devices.\u003c/p\u003e\n"],["\u003cp\u003eWhile functionally similar to the standard SDK on updated devices, the Lite SDK may encounter issues on devices with outdated or missing Google Play services, potentially impacting ad serving.\u003c/p\u003e\n"]]],["The Google Mobile Ads Lite SDK reduces app size and the number of referenced methods compared to the standard SDK, aiding developers targeting older Android versions. To implement it, add the specified dependency to the app's Gradle file. This SDK should only be used for apps distributed via the Google Play Store, as it relies on the Google Play services APK for functionality. On devices lacking or with outdated Google Play services, it might result in errors and ads not serving.\n"],null,["# Google Mobile Ads Lite SDK\n\nLike 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\n### Limitations 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------------------------\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."]]