หน้านี้จะอธิบายไลบรารี Google Play Core และวิธีเพิ่มไลบรารีดังกล่าวลงในโปรเจ็กต์
ไลบรารี Google Play Core เป็นอินเทอร์เฟซรันไทม์ของแอปกับ Google Play Store ตัวอย่างสิ่งที่คุณทำได้มีดังนี้
- ดาวน์โหลดแหล่งข้อมูลภาษาเพิ่มเติม
- จัดการการนำส่งโมดูลฟีเจอร์
- จัดการการนำส่ง Asset Pack
- ทริกเกอร์การอัปเดตในแอป
- ขอรีวิวในแอป
ไลบรารี Play Core พร้อมใช้งานใน Java, เนทีฟ และ Unity ดูข้อมูลเพิ่มเติมเกี่ยวกับรุ่นล่าสุดได้ที่บันทึกประจำรุ่น
การย้ายข้อมูลจากไลบรารี Play Core Java และ Kotlin
ไลบรารี Play Core Java และ Kotlin ได้รับการแบ่งพาร์ติชันเป็นไลบรารี Android หลายรายการตามฟีเจอร์ ซึ่งจะช่วยลดขนาดที่ไลบรารี Play Core เพิ่มลงในแอปและช่วยให้รอบการเผยแพร่ฟีเจอร์แต่ละรายการเร็วขึ้น
ลักษณะการทำงานของแต่ละฟีเจอร์ยังคงเหมือนเดิมในการย้ายข้อมูลนี้ การเปลี่ยนแปลงที่สำคัญเพียงอย่างเดียวคือเวอร์ชันใหม่ได้นำ Task API ของบริการ Google Play มาใช้
ใช้รายการด้านล่างเพื่อย้ายข้อมูลไปยังไลบรารีใหม่และรับประโยชน์จากฟีเจอร์ใหม่และการแก้ไขข้อบกพร่อง หากใช้ฟีเจอร์ Play หลายรายการ คุณสามารถนำเข้าไลบรารีหลายรายการในไฟล์ build.gradle พร้อมกันได้เลย
ขั้นตอนการย้ายข้อมูลทั่วไป
- อัปเดตคำสั่งนำเข้าที่มีอยู่ของออบเจ็กต์ Task จาก
import com.google.android.play.core.tasks.*;เป็นimport com.google.android.gms.tasks.*;ชื่อชั้นเรียนทั้งหมดจะไม่มีการเปลี่ยนแปลง - นำการนําเข้าไลบรารี Play Core เก่าในไฟล์
build.gradleออก
ผสานรวมไลบรารีการนำส่งเนื้อหา Play
ดึงดูด
// 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.3.0' // For Kotlin users also add the Kotlin extensions library for Play Asset Delivery: implementation 'com.google.android.play:asset-delivery-ktx:2.3.0' ... }
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.3.0") // For Kotlin users also import the Kotlin extensions library for Play Asset Delivery: implementation("com.google.android.play:asset-delivery-ktx:2.3.0") ... }
ผสานรวมไลบรารีการนำส่งฟีเจอร์ Play
ดึงดูด
// 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
ดึงดูด
// 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
ดึงดูด
// 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
แก้ไขล่าสุด: 24 กันยายน 2020- การใช้ชุดพัฒนาซอฟต์แวร์ Play Core หมายความว่าคุณยอมรับข้อกำหนดเหล่านี้ นอกเหนือจากข้อกำหนดในการให้บริการของ Google APIs ("ToS ของ API") หากข้อกำหนดเหล่านี้ขัดแย้งกัน ให้ถือว่าข้อกำหนดเหล่านี้มีผลเหนือกว่าข้อกำหนดในการให้บริการของ API โปรดอ่านข้อกำหนดเหล่านี้และข้อกำหนดในการให้บริการของ API อย่างละเอียด
- เพื่อวัตถุประสงค์ของข้อกำหนดเหล่านี้ "API" หมายถึง API ของ Google, บริการอื่นๆ ของนักพัฒนาซอฟต์แวร์ และซอฟต์แวร์ที่เกี่ยวข้อง รวมถึงโค้ดที่จัดจำหน่ายซ้ำได้
- "โค้ดที่เผยแพร่ซ้ำได้" หมายถึงโค้ดออบเจ็กต์หรือไฟล์ส่วนหัวที่ Google จัดเตรียมไว้ให้ซึ่งเรียกใช้ API
- คุณสามารถคัดลอกและแจกจ่ายโค้ดที่แจกจ่ายต่อได้เพื่อรวมไว้เป็นส่วนหนึ่งของไคลเอ็นต์ API เท่านั้น ทั้งนี้ขึ้นอยู่กับข้อกำหนดเหล่านี้และข้อกำหนดของ ToS ของ API Google และผู้อนุญาตเป็นเจ้าของสิทธิ กรรมสิทธิ์ และผลประโยชน์ทั้งหมด ซึ่งรวมถึงทรัพย์สินทางปัญญาและกรรมสิทธิ์อื่นๆ ทั้งหมดในและต่อโค้ดที่เผยแพร่ต่อได้ คุณจะไม่แก้ไข แปล หรือสร้างผลงานลอกเลียนแบบจากโค้ดที่เผยแพร่ต่อได้
- Google อาจทำการเปลี่ยนแปลงข้อกำหนดเหล่านี้ได้ทุกเมื่อโดยมีการแจ้งให้ทราบและให้โอกาสในการปฏิเสธการใช้งานชุดพัฒนาซอฟต์แวร์ Play Core ต่อ Google จะโพสต์ประกาศแจ้งการเปลี่ยนแปลงข้อกำหนดที่ https://developer.android.com/guide/playcore/license การเปลี่ยนแปลงจะไม่มีผลย้อนหลัง