SDK gốc Play Core

下载 Play Core Native SDK

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

条款及条件

Last modified: September 24, 2020
  1. By using the Play Core Software Development Kit, you agree to these terms in addition to the Google APIs Terms of Service ("API ToS"). If these terms are ever in conflict, these terms will take precedence over the API ToS. Please read these terms and the API ToS carefully.
  2. For purposes of these terms, "APIs" means Google's APIs, other developer services, and associated software, including any Redistributable Code.
  3. “Redistributable Code” means Google-provided object code or header files that call the APIs.
  4. Subject to these terms and the terms of the API ToS, you may copy and distribute Redistributable Code solely for inclusion as part of your API Client. Google and its licensors own all right, title and interest, including any and all intellectual property and other proprietary rights, in and to Redistributable Code. You will not modify, translate, or create derivative works of Redistributable Code.
  5. Google may make changes to these terms at any time with notice and the opportunity to decline further use of the Play Core Software Development Kit. Google will post notice of modifications to the terms at https://developer.android.com/guide/playcore/license. Changes will not be retroactive.
下载 Play Core Native SDK

play-core-native-sdk-1.14.0.zip

Bằng việc tải xuống và sử dụng SDK gốc Google Play Core, bạn đồng ý với Điều khoản dịch vụ của Bộ phát triển phần mềm Play Core.

SDK gốc Play Corei cung cấp giao diện API C/C++ cho thư viện Google Play đã chọn, bao gồm cả Play Asset Delivery SDK này được thiết kế để xây dựng các thư viện gốc ARM và x86 bằng CMake và để sử dụng Gradle để tạo các Android App Bundle và APK.

Thiết lập môi trường phát triển

  1. Thực hiện một trong hai cách sau:

    • Cài đặt phiên bản Android Studio mới nhất. Sử dụng giao diện người dùng Trình quản lý SDK để cài đặt Nền tảng SDK Android phiên bản 10.0 (API cấp độ 29).
    • Cài đặt công cụ dòng lệnh của SDK Android và sử dụng sdkmanager để cài đặt Nền tảng SDK Android phiên bản 10.0 (API cấp 29).
  2. Chuẩn bị Android Studio cho việc phát triển bằng mã gốc bằng cách dùng Trình quản lý SDK để cài đặt CMake và Bộ phát triển mã gốc Android (NDK) mới nhất. Để biết thêm thông tin về việc tạo hoặc nhập các dự án gốc, xem Bắt đầu với NDK.

  3. Tải tệp zip xuống và giải nén cùng dự án của bạn.

    Đường liên kết để tải xuống Kích thước Giá trị tổng kiểm SHA-256
    36 MiB 782a8522d937848c83a715c9a258b95a3ff2879a7cd71855d137b41c00786a5e
  4. Cập nhật tệp build.gradle của ứng dụng như minh hoạ dưới đây:

    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.2.1'
            implementation 'com.google.android.play:integrity:1.3.0'
            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.2.1")
        implementation("com.google.android.play:integrity:1.3.0")
        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. Cập nhật các tệp CMakeLists.txt của ứng dụng như hình ảnh bên dưới:

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

Điều khoản dịch vụ của Bộ phát triển phần mềm Play Core

Lần sửa đổi gần đây nhất: Ngày 24 tháng Chín năm 2020
  1. Bằng việc sử dụng Bộ công cụ phát triển phần mềm Play Core, bạn đồng ý với các điều khoản này ngoài Điều khoản dịch vụ API của Google ("API ToS"). Nếu các điều khoản này xung đột nhau, các điều khoản này sẽ được ưu tiên áp dụng hơn Điều khoản dịch vụ API. Vui lòng đọc kỹ các điều khoản này và Điều khoản dịch vụ API.
  2. Trong phạm vi các điều khoản này, "API" có nghĩa là API của Google, các dịch vụ dành cho nhà phát triển và phần mềm liên kết khác, gồm cả Mã có thể phân phối lại.
  3. “Mã có thể phân phối lại” có nghĩa là mã đối tượng hoặc tệp tiêu đề do Google cung cấp có gọi đến API.
  4. Theo các điều khoản này và điều khoản dịch vụ của API, bạn chỉ được sao chép và phân phối Mã có thể phân phối lại để đưa vào Ứng dụng API của mình. Google và bên cấp phép của Google sở hữu tất cả quyền, quyền sở hữu và lợi ích, bao gồm mọi tài sản trí tuệ cũng như các quyền sở hữu riêng khác nằm trong và đối với Mã có thể phân phối lại. Bạn không được sửa đổi, dịch hoặc tạo tác phẩm phái sinh của Mã có thể phân phối lại.
  5. Google có thể thay đổi các điều khoản này bất cứ lúc nào và sẽ đưa ra thông báo, đồng thời cho phép bạn lựa chọn ngừng sử dụng Bộ phát triển phần mềm Play Core. Google sẽ đăng thông báo về các điều khoản sửa đổi tại https://developer.android.com/guide/playcore/license. Nội dung thay đổi sẽ không có hiệu lực hồi tố.

Thu thập dữ liệu

SDK gốc của Play Core có thể thu thập một số dữ liệu liên quan đến phiên bản để cho phép Google cải thiện sản phẩm, trong đó có:

  • Tên gói của ứng dụng
  • Phiên bản gói của ứng dụng
  • Phiên bản SDK gốc của Play Core

Dữ liệu này sẽ được thu thập khi bạn tải gói ứng dụng lên Play Console. Để chọn không tham gia quá trình thu thập dữ liệu này, hãy xoá việc nhập $playcoreDir/playcore-native-metadata.jar trong tệp build.gradle.

Hãy lưu ý rằng quá trình thu thập dữ liệu này liên quan đến việc bạn sử dụng SDK gốc Play Core và việc Google sử dụng dữ liệu đã thu thập là hoạt động riêng biệt và độc lập với việc thu thập các phần phụ thuộc của thư viện được khai báo trong Gradle khi bạn tải gói ứng dụng lên Play Console.