Tổng quan về Thư viện Google Play Core

Trang này mô tả các thư viện Google Play Core và cách thêm các thư viện đó vào dự án của bạn.

Thư viện Google Play Core là giao diện thời gian chạy của ứng dụng trên Cửa hàng Google Play. Bạn có thể làm một số việc sau đây:

Thư viện Play Core hỗ trợ Java, gốcUnity. Để biết thêm thông tin về các bản phát hành mới nhất, hãy xem Ghi chú phát hành.

Di chuyển từ Thư viện Play Core Java và Kotlin

Thư viện Play Core Java và Kotlin đã được phân vùng thành nhiều thư viện Android dành cho mỗi tính năng. Điều này làm giảm kích thước các thư viện Play Core thêm vào ứng dụng của bạn, đồng thời cho phép chu kỳ phát hành của những tính năng riêng lẻ nhanh hơn.

Hành vi của từng tính năng vẫn ổn định trong quá trình di chuyển này, thay đổi duy nhất đáng chú ý là các phiên bản mới đã sử dụng API Tasks của Dịch vụ Google Play.

Sử dụng danh sách dưới đây để di chuyển sang thư viện mới và hưởng lợi nhờ các tính năng mới cũng như bản sửa lỗi. Nếu sử dụng nhiều tính năng của Play, bạn có thể chỉ cần nhập nhiều thư viện trong tệp build.gradle cùng một lúc.

Các bước di chuyển phổ biến

  1. Cập nhật mọi câu lệnh nhập hiện có của đối tượng Tác vụ từ import com.google.android.play.core.tasks.*; thành import com.google.android.gms.tasks.*;. Tất cả tên lớp đều không thay đổi.
  2. Gỡ bỏ mọi nội dung nhập của thư viện Play Core cũ trong tệp build.gradle.

Tích hợp Thư viện 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.1'

    // For Kotlin users also add the Kotlin extensions library for Play Asset Delivery:
    implementation 'com.google.android.play:asset-delivery-ktx:2.2.1'
    ...
}

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

    // For Kotlin users also import the Kotlin extensions library for Play Asset Delivery:
    implementation("com.google.android.play:asset-delivery-ktx:2.2.1")
    ...
}

Tích hợp Thư viện 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")
    ...
}

Tích hợp Thư viện bài đánh giá trong ứng dụng trên 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")
    ...
}

Tích hợp Thư viện Cập nhật trong ứng dụng trên 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")
    ...
}

Đ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ố.