เริ่มต้นใช้งานบริการเกมของ Play สำหรับเกม Android
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คู่มือนี้จะอธิบายวิธีตั้งค่าโปรเจ็กต์ Android Studio เพื่อใช้ SDK บริการเกมของ Play คุณต้องทําตามขั้นตอนเหล่านี้ให้เสร็จสมบูรณ์ก่อนจึงจะตั้งค่าการลงชื่อเข้าใช้บริการเกมของ Play และเพิ่มฟีเจอร์บริการเกมของ Play ลงในเกมได้
ก่อนเริ่มต้น
หากต้องการเตรียมแอป ให้ทำตามขั้นตอนในส่วนต่อไปนี้
ข้อกําหนดเบื้องต้นของแอป
ตรวจสอบว่าไฟล์บิลด์ของแอปใช้ค่าต่อไปนี้
minSdkVersion
จาก 19
ขึ้นไป
compileSdkVersion
จาก 28
ขึ้นไป
ตั้งค่าเกมใน Google Play Console
Google Play Console เป็นแพลตฟอร์มที่คุณจัดการบริการเกมของ Google Play สำหรับเกม รวมถึงกำหนดค่าข้อมูลเมตาสำหรับการให้สิทธิ์และตรวจสอบสิทธิ์เกม ดูข้อมูลเพิ่มเติมได้ที่ตั้งค่าบริการ Google Play Games
ในไฟล์ build.gradle
ระดับโปรเจ็กต์ ให้ใส่ที่เก็บ Maven ของ Google และที่เก็บ Maven กลาง ทั้งในส่วน buildscript
และ allprojects
buildscript {
repositories {
google()
mavenCentral()
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
เพิ่มการพึ่งพา Google Play Services สำหรับ Play Games SDK ลงในไฟล์บิลด์ Gradle ของโมดูล ซึ่งโดยทั่วไปจะอยู่ที่
app/build.gradle
:
dependencies {
implementation "com.google.android.gms:play-services-games-v2:+"
}
หลังจากทำตามขั้นตอนเหล่านี้เสร็จแล้ว คุณต้องตั้งค่าการลงชื่อเข้าใช้เพื่อให้เกมเข้าถึงฟีเจอร์ของบริการเกมของ Play ได้
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[],[],null,["# Get started with Play Games Services for Android games\n\n| **Note:** This guide is for the Play Games Services v2 SDK. For information on the previous version of this SDK, see the [Play Games Services v1\n| documentation](/games/pgs/v1/android).\n\nThis guide describes how to set up an Android Studio project to use the\nPlay Games Services SDK. You must complete these steps before you\nset up Play Games Services [sign-in](/games/pgs/android/android-signin) and add\nPlay Games Services features to your game.\n\nBefore you begin\n----------------\n\nTo prepare your app, complete the steps in the following sections.\n\n### App prerequisites\n\nMake sure that your app's build file uses the following values:\n\n- A `minSdkVersion` of `19` of higher\n- A `compileSdkVersion` of `28` or higher\n\n### Set up your game in Google Play Console\n\nThe Google Play Console is where you manage Google Play games services for your\ngame, and configure metadata for authorizing and authenticating your game. For\nmore information, see\n[Set Up Google Play Games Services](/games/pgs/console/setup).\n\nConfigure your app\n------------------\n\nIn your project-level `build.gradle` file, include\n[Google's Maven repository](https://maven.google.com/web/index.html)\nand [Maven central repository](https://search.maven.org/artifact)\nin both your `buildscript` and `allprojects` sections: \n\n buildscript {\n repositories {\n google()\n mavenCentral()\n }\n }\n\n allprojects {\n repositories {\n google()\n mavenCentral()\n }\n }\n\nAdd the [Google Play services](https://developers.google.com/android)\ndependency for the Play Games SDK to your\n[module's Gradle build file](/studio/build#module-level), which is commonly\n\n`app/build.gradle`: \n\n dependencies {\n implementation \"com.google.android.gms:play-services-games-v2:+\"\n }\n\nAfter completing these steps you must set up\n[sign-in](/games/pgs/android/android-signin)\nin order for the game to access Play Games Services features."]]