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:22.4.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,或是這些 API 已從 Google Play 服務 APK 中變更。這會導致免人工管理且記錄錯誤,可能會導致廣告無法在這類裝置上放送。