開始使用 Android 遊戲專用 Play 遊戲服務
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本指南將會說明如何設定 Android Studio 專案,以便使用 Play 遊戲服務 SDK。您必須完成以下步驟,才能設定 Play 遊戲服務登入,並在遊戲內加入 Play 遊戲服務功能。
事前準備
如要讓應用程式做好準備,請完成下列各節的步驟。
應用程式必要條件
請確認應用程式的版本檔案使用下列的值:
minSdkVersion
19
以上版本
compileSdkVersion
28
以上版本
前往 Google Play 管理中心設定您的遊戲
您可以使用 Google Play 管理中心管理遊戲的 Google Play 遊戲服務,並且設定授權和驗證遊戲所需的中繼資料。詳情請參閱「設定 Google Play 遊戲服務」。
在專案層級 build.gradle
檔案中,請同時在 buildscript
和 allprojects
區段中納入 Google Maven 存放區和 Maven 中央存放區:
buildscript {
repositories {
google()
mavenCentral()
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
將 Play 遊戲 SDK 的 Google Play 服務依附元件新增至模組的 Gradle 版本檔案,通常為
app/build.gradle
:
dependencies {
implementation "com.google.android.gms:play-services-games-v2:+"
}
完成以上步驟後,您必須設定登入流程,以便遊戲存取 Play 遊戲服務功能。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[],[],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."]]