本页面介绍了 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 服务 Task API。
使用以下列表迁移到新库,并从新功能和错误修复中获益。如果您使用多个 Play 功能,您可以一次性在 build.gradle
文件中导入多个库。
常见迁移步骤
- 将 Task 对象的任何现有 import 语句从
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.3.0' // For Kotlin users also add the Kotlin extensions library for Play Asset Delivery: implementation 'com.google.android.play:asset-delivery-ktx:2.3.0' ... }
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.3.0") // For Kotlin users also import the Kotlin extensions library for Play Asset Delivery: implementation("com.google.android.play:asset-delivery-ktx:2.3.0") ... }
集成 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 上发布条款修改通知。更改不会追溯生效。