Google Play Core 库概述

此页面介绍了 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文件中同时导入多个库即可。

常见的迁移步骤

  1. 将 Task 对象的任何现有导入语句从import com.google.android.play.core.tasks.*;更新为import com.google.android.gms.tasks.*;。所有类名均保持不变。
  2. 删除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.1'

    // For Kotlin users, also add the Kotlin extensions library for Play In-App Review:
    implementation 'com.google.android.play:review-ktx:2.0.1'
    ...
}

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.1")

    // For Kotlin users, also import the Kotlin extensions library for Play In-App Review:
    implementation("com.google.android.play:review-ktx:2.0.1")
    ...
}

集成 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日
  1. 使用 Play Core 软件开发工具包即表示您同意这些条款,以及Google API 服务条款(“API 服务条款”)。如果这些条款之间存在冲突,则这些条款将优先于 API 服务条款。请仔细阅读这些条款和 API 服务条款。
  2. 就本条款而言,“API”是指 Google 的 API、其他开发者服务和相关软件,包括任何可再发行代码。
  3. “可再发行代码”是指 Google 提供的调用 API 的对象代码或头文件。
  4. 根据这些条款和 API 服务条款,您仅可在将可再发行代码作为 API 客户端的一部分包含在内时复制和分发该代码。Google 及其许可方拥有可再发行代码中所有权利、所有权和权益,包括任何及所有知识产权和其他专有权利。您不得修改、翻译或创建可再发行代码的衍生作品。
  5. Google 可以随时更改这些条款,并会提供通知以及拒绝继续使用 Play Core 软件开发工具包的机会。Google 将在https://developer.android.com/guide/playcore/license上发布条款修改的通知。更改不具有追溯效力。