Android 免安裝應用程式中的 AdMob
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 免安裝應用程式可讓使用者立即執行 Android 應用程式,無須安裝。本指南適用於想透過 AdMob 營利的 Android 免安裝應用程式發布商。
必要條件
- 使用 Android Studio 3.0 Canary 1 以上版本
- 免安裝應用程式開發 SDK
- Android SDK Platform 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:24.4.0'
...
}
加入上述以粗體顯示的程式碼行,指示 Gradle 提取最新版本的 Mobile Ads Lite SDK。完成後,請儲存檔案並執行 Gradle 同步作業。
Lite SDK 隨附在 Google 存放區中,因此 Android Studio 可能會顯示訊息,要求您安裝這個 SDK。如果是,只要同意下載,Android Studio 就會處理後續作業。
後續步驟
如要顯示 AdMob 廣告並賺取收益,接下來請初始化 Mobile Ads SDK,並選擇廣告格式。
使用 AdMob 透過 Android Instant App 營利時,Google 中介服務並未獲得正式支援。即時應用程式顯示的所有網頁內容都必須透過安全連線載入。AdMob 廣告符合這項規定,但第三方廣告聯播網的廣告可能不符合。因此,建議您透過 AdMob 放送 Android Instant App 時,建立不使用中介服務的新廣告單元。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-24 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-24 (世界標準時間)。"],[[["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"]]