Android 免安裝應用程式中的 AdMob
Android 免安裝應用程式可讓 Android 應用程式立即執行,無須安裝。本指南適用於想透過 AdMob 為 Android 即時應用程式營利的發布商。
必要條件
- 使用 Android Studio 3.0 Canary 1 以上版本
- 免安裝應用程式開發 SDK
- Android SDK 平台 O
- 指定 Android API 級別 14 以上版本
匯入 Mobile Ads SDK
Android 免安裝應用程式必須以網址可尋址的模組進行結構化,且大小不得超過 4 MB。為了符合這個大小限制,建議您使用 Google Mobile Ads Lite SDK 而非標準版。如要進一步瞭解 Lite SDK (包括其限制),請參閱 Lite SDK 指南。
應用程式可以使用 Gradle 依附元件匯入 Google Mobile Ads Lite SDK。開啟應用程式的應用程式層級 build.gradle 檔案,然後尋找「dependencies」部分。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.gms:play-services-ads-lite:23.6.0'
...
}
新增上方以粗體顯示的行,指示 Gradle 擷取最新版本的 Mobile Ads Lite SDK。完成後,請儲存檔案並執行 Gradle 同步作業。
Lite SDK 是 Google 存放區的一部分,因此您可能會看到 Android Studio 要求您安裝的訊息。如果是,請同意下載,Android Studio 會負責處理後續作業。
後續步驟
接下來,您需要初始化 Mobile Ads SDK,並選擇廣告格式,才能顯示 AdMob 廣告並賺取收益。
使用 AdMob 為 Android 即時應用程式營利時,Google 中介服務並未獲得正式支援。即時應用程式要求所有顯示的網頁內容都必須透過安全連線載入。AdMob 廣告符合這項規定,但第三方廣告聯播網的廣告可能不符合規定。因此,建議您在使用 AdMob 為 Android 即時應用程式營利時,建立不使用中介服務的新廣告單元。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-02-20 (世界標準時間)。
[null,null,["上次更新時間:2025-02-20 (世界標準時間)。"],[[["Android Instant Apps allow Android apps to run instantly without installation, and this guide focuses on monetizing them with AdMob."],["Developers need to use Android Studio 3.0 Canary 1 or higher, Instant Apps Development SDK, Android SDK Platform O, and target Android API level 14 or higher as prerequisites."],["It's recommended to integrate the Google Mobile Ads Lite SDK for optimal size management within Instant Apps, and instructions for adding it via Gradle are provided."],["Mediation with third-party ad networks isn't officially supported in Instant Apps due to security requirements for web content."]]],["Android Instant Apps run without installation, and this guide focuses on monetizing them with AdMob. Publishers must use Android Studio 3.0+, the Instant Apps Development SDK, and target API level 14+. Due to size constraints (under 4MB), the Google Mobile Ads Lite SDK is recommended, imported via Gradle dependency in the `build.gradle` file. Initialize the Mobile Ads SDK and choose an ad format to display ads. Google mediation is not supported in instant apps.\n"]]