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 服务的 Tasks API

您可以使用下面的列表迁移到新库,并从新功能和 bug 修复中获益。如果您使用多个 Play 功能,您还可以一次性在 build.gradle 文件中导入多个库。

常见的迁移步骤

  1. 将 Tasks 对象的所有现有 import 语句从 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.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 日
  1. 使用 Play Core 软件开发套件,即表示您同意在遵守《Google API 服务条款》(以下简称“《API 服务条款》”)的同时,也遵守这些条款。如果这些条款与《API 服务条款》存在冲突,请以这些条款为准。请仔细阅读这些条款和《API 服务条款》。
  2. 就这些条款而言,“API”是指 Google 的 API、其他开发者服务和相关软件(包括任何可再分发代码)。
  3. “可再分发代码”是指 Google 提供的调用 API 的对象代码或头文件。
  4. 根据这些条款和《API 服务条款》的规定,您只能在将可再分发代码纳入您的 API 客户端时对其进行复制和分发。Google 及其许可人拥有可再分发代码的所有权利、所有权和利益,包括任何及所有知识产权和其他专有权利。您不得修改、翻译可再分发代码,也不得创作可再分发代码的衍生作品。
  5. Google 随时可变更这些条款。如有变更,Google 会向您发出通知,同时您也可以选择不继续使用 Play Core 软件开发套件。Google 会在此网址 (https://developer.android.com/guide/playcore/license) 上发布条款修改通知。变更不具有追溯效力。