此页面介绍了 Google Play Core 库以及如何将它们添加到您的项目中。
Google Play Core 库是您的应用与 Google Play 商店之间的运行时接口。您可以执行的一些操作包括以下内容
Play Core 库在Java、原生和Unity中可用。有关最新版本的更多信息,请参阅发行说明。
从 Play Core Java 和 Kotlin 库迁移
Play Core Java 和 Kotlin 库已划分为多个按功能划分的 Android 库。这减少了 Play Core 库添加到您的应用中的大小,并允许更快地发布各个功能。
每个功能的行为在此迁移中保持一致,唯一值得注意的变化是新版本已采用Google Play 服务的任务 API。
使用以下列表迁移到新库并从新功能和错误修复中受益。如果您使用多个 Play 功能,只需在您的build.gradle
文件中一次导入多个库即可。
常见迁移步骤
- 将 Task 对象的任何现有导入语句从
import com.google.android.play.core.tasks.*;
更新为import com.google.android.gms.tasks.*;
。所有类名均保持不变。 - 删除
build.gradle
文件中旧版 Play Core 库的任何导入。
集成 Play Asset Delivery 库
Groovy
// In your app’s build.gradle file: ... dependencies { // This dependency is downloaded from the Google’s Maven repository. // So, make sure you also include that repository in your project's build.gradle file. implementation 'com.google.android.play:asset-delivery:2.2.2' // For Kotlin users also add the Kotlin extensions library for Play Asset Delivery: implementation 'com.google.android.play:asset-delivery-ktx:2.2.2' ... }
Kotlin
// In your app’s build.gradle.kts file: ... dependencies { // This dependency is downloaded from the Google’s Maven repository. // So, make sure you also include that repository in your project's build.gradle file. implementation("com.google.android.play:asset-delivery:2.2.2") // For Kotlin users also import the Kotlin extensions library for Play Asset Delivery: implementation("com.google.android.play:asset-delivery-ktx:2.2.2") ... }
集成 Play Feature Delivery 库
Groovy
// In your app’s build.gradle file: ... dependencies { // This dependency is downloaded from the Google’s Maven repository. // So, make sure you also include that repository in your project's build.gradle file. implementation 'com.google.android.play:feature-delivery:2.1.0' // For Kotlin users, also add the Kotlin extensions library for Play Feature Delivery: implementation 'com.google.android.play:feature-delivery-ktx:2.1.0' ... }
Kotlin
// In your app’s build.gradle.kts file: ... dependencies { // This dependency is downloaded from the Google’s Maven repository. // Make sure you also include that repository in your project's build.gradle file. implementation("com.google.android.play:feature-delivery:2.1.0") // For Kotlin users, also import the Kotlin extensions library for Play Feature Delivery: implementation("com.google.android.play:feature-delivery-ktx:2.1.0") ... }
集成 Play 应用内评价库
Groovy
// In your app’s build.gradle file: ... dependencies { // This dependency is downloaded from the Google’s Maven repository. // Make sure you also include that repository in your project's build.gradle file. implementation 'com.google.android.play:review:2.0.2' // For Kotlin users, also add the Kotlin extensions library for Play In-App Review: implementation 'com.google.android.play:review-ktx:2.0.2' ... }
Kotlin
// In your app’s build.gradle.kts file: ... dependencies { // This dependency is downloaded from the Google’s Maven repository. // Make sure you also include that repository in your project's build.gradle file. implementation("com.google.android.play:review:2.0.2") // For Kotlin users, also import the Kotlin extensions library for Play In-App Review: implementation("com.google.android.play:review-ktx:2.0.2") ... }
集成 Play 应用内更新库
Groovy
// In your app’s build.gradle file: ... dependencies { // This dependency is downloaded from the Google’s Maven repository. // Make sure you also include that repository in your project's build.gradle file. implementation 'com.google.android.play:app-update:2.1.0' // For Kotlin users, also add the Kotlin extensions library for Play In-App Update: implementation 'com.google.android.play:app-update-ktx:2.1.0' ... }
Kotlin
// In your app’s build.gradle.kts file: ... dependencies { // This dependency is downloaded from the Google’s Maven repository. // Make sure you also include that repository in your project's build.gradle file. implementation("com.google.android.play:app-update:2.1.0") // For Kotlin users, also import the Kotlin extensions library for Play In-App Update: implementation("com.google.android.play:app-update-ktx:2.1.0") ... }
Play Core 软件开发工具包服务条款
上次修改时间:2020 年 9 月 24 日- 通过使用 Play Core 软件开发工具包,您同意这些条款以及Google API 服务条款(“API 服务条款”)。如果这些条款之间存在冲突,则这些条款将优先于 API 服务条款。请仔细阅读这些条款和 API 服务条款。
- 出于这些条款的目的,“API”是指 Google 的 API、其他开发者服务和相关软件,包括任何可再发行代码。
- “可再发行代码”是指 Google 提供的对象代码或调用 API 的头文件。
- 根据这些条款和 API 服务条款,您只能为了将其包含在 API 客户端中而复制和分发可再发行代码。Google 及其许可方拥有可再发行代码中所有权利、所有权和权益,包括任何及所有知识产权和其他专有权利。您不得修改、翻译或创建可再发行代码的衍生作品。
- Google 可能会随时更改这些条款,并提供通知以及拒绝进一步使用 Play Core 软件开发工具包的机会。Google 将在https://developer.android.com/guide/playcore/license上发布对条款修改的通知。更改不会追溯适用。