下载 Play Core Native SDK

您必须先接受以下条款及条件才能下载。

条款及条件

上次修改时间: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 上发布条款修改通知。变更不具有追溯效力。
下载 Play Core Native SDK

play-core-native-sdk-1.12.1.zip

Play Core 原生 SDK

下载并使用 Google Play Core 原生 SDK,即表示您同意接受《Play Core 软件开发套件服务条款》。

Play Core 原生 SDK 可为选定的 Google Play 库(包括 Play Asset Delivery)提供 C/C++ API 接口。该 SDK 设计用于使用 CMake 构建 ARM 和 x86 原生库,以及使用 Gradle 生成 Android App Bundle 和 APK。

设置您的开发环境

  1. 执行以下其中一项操作:

  2. 使用 SDK 管理器安装最新的 CMake 和 Android 原生开发套件 (NDK),让 Android Studio 做好原生开发准备。如需详细了解如何创建或导入原生项目,请参阅 NDK 入门指南

  3. 下载 zip 文件并将其解压缩到您的项目所在位置。

    下载链接 大小 SHA-256 校验和
    70.9 MiB 84c9e9579f05d6e29bbbd9c9cde2fde8210947f2007866b0045f4c40fabb7368
  4. 更新应用的 build.gradle 文件,如下所示:

    Groovy

        // App build.gradle
    
        plugins {
          id 'com.android.application'
        }
    
        // Define a path to the extracted Play Core SDK files.
        // If using a relative path, wrap it with file() since CMake requires absolute paths.
        def playcoreDir = file('../path/to/playcore-native-sdk')
    
        android {
            defaultConfig {
                ...
                externalNativeBuild {
                    cmake {
                        // Define the PLAYCORE_LOCATION directive.
                        arguments "-DANDROID_STL=c++_static",
                                  "-DPLAYCORE_LOCATION=$playcoreDir"
                    }
                }
                ndk {
                    // Skip deprecated ABIs. Only required when using NDK 16 or earlier.
                    abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
                }
            }
            buildTypes {
                release {
                    // Include Play Core Library proguard config files to strip unused code while retaining the Java symbols needed for JNI.
                    proguardFile '$playcoreDir/proguard/common.pgcfg'
                    proguardFile '$playcoreDir/proguard/gms_task.pgcfg'
                    proguardFile '$playcoreDir/proguard/per-feature-proguard-files'
                    ...
                }
                debug {
                    ...
                }
            }
            externalNativeBuild {
                cmake {
                    path 'src/main/CMakeLists.txt'
                }
            }
        }
    
        dependencies {
            // Import these feature-specific AARs for each Google Play Core library.
            implementation 'com.google.android.play:app-update:2.0.0'
            implementation 'com.google.android.play:asset-delivery:2.0.0'
            implementation 'com.google.android.play:integrity:1.1.0-beta01'
            implementation 'com.google.android.play:review:2.0.0'
    
            // Import these common dependencies.
            implementation 'com.google.android.gms:play-services-tasks:18.0.2'
            implementation files("$playcoreDir/playcore-native-metadata.jar")
            ...
        }
        

    Kotlin

    // App build.gradle.kts
    
    plugins {
        id("com.android.application")
    }
    
    // Define a path to the extracted Play Core SDK files.
    // If using a relative path, wrap it with file() since CMake requires absolute paths.
    val playcoreDir = file("../path/to/playcore-native-sdk")
    
    android {
        defaultConfig {
            ...
            externalNativeBuild {
                cmake {
                    // Define the PLAYCORE_LOCATION directive.
                    arguments += listOf("-DANDROID_STL=c++_static", "-DPLAYCORE_LOCATION=$playcoreDir")
                }
            }
            ndk {
                // Skip deprecated ABIs. Only required when using NDK 16 or earlier.
                abiFilters.clear()
                abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
            }
        }
        buildTypes {
            release {
                // Include Play Core Library proguard config files to strip unused code while retaining the Java symbols needed for JNI.
                proguardFile("$playcoreDir/proguard/common.pgcfg")
                proguardFile("$playcoreDir/proguard/gms_task.pgcfg")
                proguardFile("$playcoreDir/proguard/per-feature-proguard-files")
                ...
            }
            debug {
                ...
            }
        }
        externalNativeBuild {
            cmake {
                path = "src/main/CMakeLists.txt"
            }
        }
    }
    
    dependencies {
        // Import these feature-specific AARs for each Google Play Core library.
        implementation("com.google.android.play:app-update:2.0.0")
        implementation("com.google.android.play:asset-delivery:2.0.0")
        implementation("com.google.android.play:integrity:1.1.0-beta01")
        implementation("com.google.android.play:review:2.0.0")
    
        // Import these common dependencies.
        implementation("com.google.android.gms:play-services-tasks:18.0.2")
        implementation(files("$playcoreDir/playcore-native-metadata.jar"))
        ...
    }
    
  5. 更新应用的 CMakeLists.txt 文件,如下所示:

    cmake_minimum_required(VERSION 3.6)
    
    ...
    
    # Add a static library called “playcore” built with the c++_static STL.
    include(${PLAYCORE_LOCATION}/playcore.cmake)
    add_playcore_static_library()
    
    // In this example “main” is your native code library, i.e. libmain.so.
    add_library(main SHARED
            ...)
    
    target_include_directories(main PRIVATE
            ${PLAYCORE_LOCATION}/include
            ...)
    
    target_link_libraries(main
            android
            playcore
            ...)
    

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 上发布条款修改通知。变更不具有追溯效力。

数据收集

Play Core 原生 SDK 可能会收集版本相关数据,以便 Google 改进产品,包括:

  • 应用的软件包名称
  • 应用的软件包版本
  • Play Core 原生 SDK 的版本

当您将应用软件包上传到 Play 管理中心时,系统会收集这些数据。如需停用此数据收集流程,请移除 build.gradle 文件中的 $playcoreDir/playcore-native-metadata.jar 导入项。

请注意,这种与使用 Play Core 原生 SDK 相关的数据收集行为以及 Google 使用所收集数据的行为,与您将应用软件包上传至 Play 管理中心时 Google 收集在 Gradle 中声明的库依赖项无关且相互独立。