Android 免安装应用中的 AdMob
借助 Android 免安装应用,您无需安装就可立即运行 Android 应用。本指南面向希望通过 AdMob 通过 Android 免安装应用创收的发布商。
前提条件
- 使用 Android Studio 3.0 Canary 1 或更高版本
- 免安装应用开发 SDK
- Android SDK Platform O
- 以 Android API 级别 14 或更高级别为目标平台
导入移动广告 SDK
Android 免安装应用需要构建为大小不超过 4MB 且可通过网址寻址的模块。为帮助您遵守此大小限制,建议您使用 Google 移动广告 SDK 精简版,而不是标准版。如需详细了解 Lite SDK(包括其局限性),请参阅 Lite SDK 指南。
应用可以使用 Gradle 依赖项导入 Google 移动广告 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 提取最新版本的移动广告 SDK 精简版。添加完该代码后,请保存文件并执行“Gradle sync”。
SDK 精简版作为 Google 代码库的一部分分发,因此您可能会看到一条来自 Android Studio 的消息,要求您安装它。如果是,只需同意下载,Android Studio 会负责其余工作。
后续步骤
就展示 AdMob 广告并赚取收入而言,后续的步骤是初始化移动广告 SDK 和选择广告格式。
使用 AdMob 通过 Android Instant 应用创收时,Google 中介尚未获得正式支持。免安装应用要求通过安全连接加载显示的所有网页内容。AdMob 中的广告符合此要求,但第三方广告联盟中的广告可能不符合。因此,在借助 AdMob 通过 Android 免安装应用创收时,我们建议您创建一个不使用中介的新广告单元。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-20。
[null,null,["最后更新时间 (UTC):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"]]