เอกสารนี้อธิบายวิธีย้ายข้อมูลเกมที่มีอยู่จาก SDK v1 ของ Games ไปยัง SDK v2 ของ Games
ก่อนเริ่มต้น
คุณสามารถใช้ IDE ที่ต้องการ เช่น Android Studio เพื่อย้ายข้อมูลเกมได้ ทำตามขั้นตอนต่อไปนี้ให้เรียบร้อยก่อนที่จะย้ายข้อมูลไปยังเกม v2
- ดาวน์โหลดและติดตั้ง Android Studio
 - เกมของคุณต้องใช้ SDK v1 ของ Games
 
อัปเดตการอ้างอิง
ในไฟล์
build.gradleของโมดูล ให้ค้นหาบรรทัดนี้ในทรัพยากร Dependency ระดับโมดูลimplementation "com.google.android.gms:play-services-games:+"แทนที่ด้วยโค้ดต่อไปนี้
implementation "com.google.android.gms:play-services-games-v2:version"แทนที่ version ด้วย SDK ของเกมเวอร์ชันล่าสุด
หลังจากอัปเดตการขึ้นต่อกันแล้ว โปรดทำตามขั้นตอนทั้งหมดใน เอกสารนี้
กำหนดรหัสโปรเจ็กต์
หากต้องการเพิ่มรหัสโปรเจ็กต์ SDK บริการเกมของ Google Play ลงในแอป ให้ทำตาม ขั้นตอนต่อไปนี้
ในไฟล์
AndroidManifest.xmlให้เพิ่มองค์ประกอบและแอตทริบิวต์<meta-data>ต่อไปนี้ลงในองค์ประกอบ<application><manifest> <application> <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/game_services_project_id"/> </application> </manifest>กำหนดการอ้างอิงทรัพยากร String
@string/game_services_project_idโดยใช้รหัสโปรเจ็กต์บริการเกมของเกมเป็นค่า คุณดูรหัสโปรเจ็กต์บริการเกมได้ใต้ชื่อเกมในหน้าการกำหนดค่าใน Google Play Consoleในไฟล์
res/values/strings.xmlให้เพิ่มการอ้างอิงทรัพยากรสตริง และตั้งค่ารหัสโปรเจ็กต์เป็นค่า เช่น<!-- res/values/strings.xml --> <resources> <!-- Replace 0000000000 with your game’s project id. Example value shown above. --> <string translatable="false" name="game_services_project_id"> 0000000000 </string> </resources>
ย้ายข้อมูลจาก Google Sign-In ที่เลิกใช้งานแล้ว
แทนที่คลาส GoogleSignInClient
ด้วยคลาส GamesSignInClient
Java
ค้นหาไฟล์ที่มีคลาส GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
// ... existing code
@Override
public void onCreate(@Nullable Bundle bundle) {
    super.onCreate(bundle);
    // ... existing code
    GoogleSignInOptions signInOption =
        new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build();
    
    // Client used to sign in to Google services
    GoogleSignInClient googleSignInClient =
        GoogleSignIn.getClient(this, signInOptions);
}
และอัปเดตเป็น
import com.google.android.gms.games.PlayGamesSdk;
import com.google.android.gms.games.PlayGames;
import com.google.android.gms.games.GamesSignInClient;
// ... existing code
@Override
public void onCreate(){
    super.onCreate();
    PlayGamesSdk.initialize(this);
    // Client used to sign in to Google services
    GamesSignInClient gamesSignInClient =
        PlayGames.getGamesSignInClient(getActivity());
}
Kotlin
ค้นหาไฟล์ที่มีคลาส GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
// ... existing code
val signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN
// ... existing code
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val googleSignInClient: GoogleSignInClient =
        GoogleSignIn.getClient(this, signInOptions)
}
และอัปเดตเป็น
import com.google.android.gms.games.PlayGames
import com.google.android.gms.games.PlayGamesSdk
import com.google.android.gms.games.GamesSignInClient
// ... existing code
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    PlayGamesSdk.initialize(this)
    // client used to sign in to Google services
    val gamesSignInClient: GamesSignInClient =
        PlayGames.getGamesSignInClient(this)
}
อัปเดตรหัส GoogleSignIn
GoogleSignIn API
ไม่รองรับใน SDK v2 ของเกม แทนที่โค้ด GoogleSignIn API
 ด้วย GamesSignInClient API ตามที่แสดงในตัวอย่างต่อไปนี้
หากต้องการขอโทเค็นเพื่อการเข้าถึงฝั่งเซิร์ฟเวอร์ ให้ใช้วิธี GamesSignInClient.requestServerSideAccess()
ดูข้อมูลเพิ่มเติมได้ที่
อัปเดตคลาสการเข้าถึงฝั่งเซิร์ฟเวอร์
Java
ค้นหาไฟล์ที่มีคลาส GoogleSignIn
// Request code used when invoking an external activity.
private static final int RC_SIGN_IN = 9001;
private boolean isSignedIn() {
    GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
    GoogleSignInOptions signInOptions =
    GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN;
    return GoogleSignIn.hasPermissions(account, signInOptions.getScopeArray());
}
private void signInSilently() {
    GoogleSignInOptions signInOptions =
        GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN;
    GoogleSignInClient signInClient = GoogleSignIn.getClient(this, signInOptions);
    signInClient
        .silentSignIn()
        .addOnCompleteListener(
            this,
            task -> {
            if (task.isSuccessful()) {
                // The signed-in account is stored in the task's result.
                GoogleSignInAccount signedInAccount = task.getResult();
                showSignInPopup();
            } else {
                // Perform interactive sign in.
                startSignInIntent();
            }
        });
}
private void startSignInIntent() {
    GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
        GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
    Intent intent = signInClient.getSignInIntent();
    startActivityForResult(intent, RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result =
        Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // The signed-in account is stored in the result.
            GoogleSignInAccount signedInAccount = result.getSignInAccount();
            showSignInPopup();
        } else {
            String message = result.getStatus().getStatusMessage();
            if (message == null || message.isEmpty()) {
                message = getString(R.string.signin_other_error);
        }
        new AlertDialog.Builder(this).setMessage(message)
            .setNeutralButton(android.R.string.ok, null).show();
        }
    }
}
private void showSignInPopup() {
Games.getGamesClient(requireContext(), signedInAccount)
    .setViewForPopups(contentView)
    .addOnCompleteListener(
        task -> {
            if (task.isSuccessful()) {
                logger.atInfo().log("SignIn successful");
            } else {
                logger.atInfo().log("SignIn failed");
            }
        });
  }
และอัปเดตเป็น
private void signInSilently() {
    gamesSignInClient.isAuthenticated().addOnCompleteListener(isAuthenticatedTask -> {
    boolean isAuthenticated =
        (isAuthenticatedTask.isSuccessful() &&
            isAuthenticatedTask.getResult().isAuthenticated());
        if (isAuthenticated) {
            // Continue with Play Games Services
        } else {
            // If authentication fails, either disable Play Games Services
            // integration or
            // display a login button to prompt players to sign in.
            // Use`gamesSignInClient.signIn()` when the login button is clicked.
        }
    });
}
@Override
protected void onResume() {
    super.onResume();
    // When the activity is inactive, the signed-in user's state can change;
    // therefore, silently sign in when the app resumes.
    signInSilently();
}Kotlin
ค้นหาไฟล์ที่มีคลาส GoogleSignIn
// Request codes we use when invoking an external activity.
private val RC_SIGN_IN = 9001
// ... existing code
private fun isSignedIn(): Boolean {
    val account = GoogleSignIn.getLastSignedInAccount(this)
    val signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN
    return GoogleSignIn.hasPermissions(account, *signInOptions.scopeArray)
}
private fun signInSilently() {
    val signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN
    val signInClient = GoogleSignIn.getClient(this, signInOptions)
    signInClient.silentSignIn().addOnCompleteListener(this) { task ->
        if (task.isSuccessful) {
            // The signed-in account is stored in the task's result.
            val signedInAccount = task.result
            // Pass the account to showSignInPopup.
            showSignInPopup(signedInAccount)
        } else {
            // Perform interactive sign in.
            startSignInIntent()
        }
    }
}
private fun startSignInIntent() {
    val signInClient = GoogleSignIn.getClient(this, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
    val intent = signInClient.signInIntent
    startActivityForResult(intent, RC_SIGN_IN)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == RC_SIGN_IN) {
        val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
        if (result.isSuccess) {
            // The signed-in account is stored in the result.
            val signedInAccount = result.signInAccount
            showSignInPopup(signedInAccount) // Pass the account to showSignInPopup.
        } else {
            var message = result.status.statusMessage
            if (message == null || message.isEmpty()) {
                message = getString(R.string.signin_other_error)
        }
        AlertDialog.Builder(this)
            .setMessage(message)
            .setNeutralButton(android.R.string.ok, null)
            .show()
        }
    }
}
private fun showSignInPopup(signedInAccount: GoogleSignInAccount) {
    // Add signedInAccount parameter.
    Games.getGamesClient(this, signedInAccount)
        .setViewForPopups(contentView) // Assuming contentView is defined.
        .addOnCompleteListener { task ->
        if (task.isSuccessful) {
            logger.atInfo().log("SignIn successful")
        } else {
            logger.atInfo().log("SignIn failed")
        }
    }
}และอัปเดตเป็น
private fun signInSilently() {
    gamesSignInClient.isAuthenticated.addOnCompleteListener { isAuthenticatedTask ->
        val isAuthenticated = isAuthenticatedTask.isSuccessful &&
        isAuthenticatedTask.result.isAuthenticated
        if (isAuthenticated) {
            // Continue with Play Games Services
        } else {
            // To handle a user who is not signed in, either disable Play Games Services integration
            // or display a login button. Selecting this button calls `gamesSignInClient.signIn()`.
        }
    }
}
override fun onResume() {
    super.onResume()
    // Since the state of the signed in user can change when the activity is
    // not active it is recommended to try and sign in silently from when the
    // app resumes.
    signInSilently()
}เพิ่มโค้ด GamesSignInClient
หากผู้เล่นได้รับการตรวจสอบสิทธิ์เรียบร้อยแล้ว ให้นำปุ่มลงชื่อเข้าใช้บริการเกมของ Play
ออกจากเกม หากผู้ใช้เลือกที่จะไม่ตรวจสอบสิทธิ์เมื่อเกมเปิดตัว
ให้แสดงปุ่มที่มีไอคอนบริการเกมของ Play ต่อไป
และเริ่มกระบวนการเข้าสู่ระบบด้วย
GamesSignInClient.signIn()
Java
private void startSignInIntent() {
    gamesSignInClient
        .signIn()
        .addOnCompleteListener( task -> {
            if (task.isSuccessful() && task.getResult().isAuthenticated()) {
                // sign in successful
            } else {
                // sign in failed
            }
        });
  }Kotlin
private fun startSignInIntent() {
    gamesSignInClient
        .signIn()
        .addOnCompleteListener { task ->
            if (task.isSuccessful && task.result.isAuthenticated) {
                // sign in successful
            } else {
                // sign in failed
            }
        }
  }นำรหัสลงชื่อออกออก
นำรหัสสำหรับ GoogleSignInClient.signOut ออก
นำโค้ดที่แสดงในตัวอย่างต่อไปนี้ออก
Java
// ... existing code
private void signOut() {
    GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
    GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
    signInClient.signOut().addOnCompleteListener(this,
    new OnCompleteListener() {
        @Override
        public void onComplete(@NonNull Task task) {
           // At this point, the user is signed out.
        }
    });
}  Kotlin
// ... existing code
private fun signOut() {
    val signInClient = GoogleSignIn.getClient(this, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
    signInClient.signOut().addOnCompleteListener(this) {
    // At this point, the user is signed out.
    }
}ตรวจสอบการตรวจสอบสิทธิ์ที่สำเร็จ
ใส่โค้ดต่อไปนี้เพื่อตรวจสอบว่าคุณได้ตรวจสอบสิทธิ์โดยอัตโนมัติหรือไม่ และ เพิ่มตรรกะที่กำหนดเองหากมี
Java
private void checkIfAutomaticallySignedIn() {
gamesSignInClient.isAuthenticated().addOnCompleteListener(isAuthenticatedTask -> {
boolean isAuthenticated =
    (isAuthenticatedTask.isSuccessful() &&
    isAuthenticatedTask.getResult().isAuthenticated());
    if (isAuthenticated) {
        // Continue with Play Games Services
        // If your game requires specific actions upon successful sign-in,
        // you can add your custom logic here.
        // For example, fetching player data or updating UI elements.
    } else {
        // Show a login button to ask  players to sign-in. Clicking it should
        // call GamesSignInClient.signIn().
        }
    });
}
Kotlin
private void checkIfAutomaticallySignedIn() {
gamesSignInClient.isAuthenticated()
    .addOnCompleteListener { task ->
    val isAuthenticated = task.isSuccessful && task.result?.isAuthenticated ?: false
        if (isAuthenticated) {
            // Continue with Play Games Services
        } else {
            // Disable your integration or show a login button
        }
    }
}
อัปเดตชื่อคลาสและเมธอดของไคลเอ็นต์
เมื่อย้ายข้อมูลไปยังเกม v2 วิธีที่ใช้ในการรับชื่อคลาสไคลเอ็นต์
จะแตกต่างกัน
ให้ใช้วิธีการ
PlayGames.getxxxClient()
ที่เกี่ยวข้องแทนวิธีการ
Games.getxxxClient()
เช่น สำหรับ
LeaderboardsClient
ให้ใช้ PlayGames.getLeaderboardsClient() แทน
Games.getLeaderboardsClient()
นำโค้ดที่เกี่ยวข้องกับคลาส GamesClient และ GamesMetadataClient ออก
เนื่องจากเราไม่มีคลาสทดแทนใน Games v2
Java
ค้นหารหัสสำหรับ LeaderboardsClient
import com.google.android.gms.games.LeaderboardsClient;
import com.google.android.gms.games.Games;
@Override
public void onCreate(@Nullable Bundle bundle) {
    super.onCreate(bundle);
        // Get the leaderboards client using Play Games services.
    LeaderboardsClient leaderboardsClient = Games.getLeaderboardsClient(this,
        GoogleSignIn.getLastSignedInAccount(this));
}
และอัปเดตเป็น
import com.google.android.gms.games.LeaderboardsClient;
import com.google.android.gms.games.PlayGames;
 @Override
public void onCreate(@Nullable Bundle bundle) {
    super.onCreate(bundle);
        // Get the leaderboards client using Play Games services.
        LeaderboardsClient leaderboardsClient = PlayGames.getLeaderboardsClient(getActivity());
}
Kotlin
ค้นหารหัสสำหรับ LeaderboardsClient
import com.google.android.gms.games.LeaderboardsClient
import com.google.android.gms.games.Games
// Initialize the variables.
private lateinit var leaderboardsClient: LeaderboardsClient
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    leaderboardsClient = Games.getLeaderboardsClient(this,
        GoogleSignIn.getLastSignedInAccount(this))
}และอัปเดตเป็น
import com.google.android.gms.games.LeaderboardsClient
import com.google.android.gms.games.PlayGames
    // Initialize the variables.
private lateinit var leaderboardsClient: LeaderboardsClient
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    leaderboardsClient = PlayGames.getLeaderboardsClient(this)
}ในทำนองเดียวกัน ให้ใช้วิธีการที่เกี่ยวข้องสำหรับไคลเอ็นต์ต่อไปนี้
AchievementsClient, EventsClient, GamesSignInClient,
PlayerStatsClient, RecallClient, SnapshotsClient หรือ PlayersClient
อัปเดตคลาสการเข้าถึงฝั่งเซิร์ฟเวอร์
หากต้องการขอโทเค็นเพื่อการเข้าถึงฝั่งเซิร์ฟเวอร์ ให้ใช้เมธอด
GamesSignInClient.requestServerSideAccess()
 แทนเมธอด
GoogleSignInAccount.getServerAuthCode()
ดูข้อมูลเพิ่มเติมได้ที่ส่งรหัสการให้สิทธิ์ของเซิร์ฟเวอร์
ตัวอย่างต่อไปนี้แสดงวิธีขอโทเค็นเพื่อการเข้าถึงฝั่งเซิร์ฟเวอร์
Java
ค้นหารหัสสำหรับชั้นเรียน GoogleSignInOptions
    private static final int RC_SIGN_IN = 9001;
    private GoogleSignInClient googleSignInClient;
    private void startSignInForAuthCode() {
        /** Client ID for your backend server. */
        String webClientId = getString(R.string.webclient_id);
        GoogleSignInOptions signInOption = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
            .requestServerAuthCode(webClientId)
            .build();
        GoogleSignInClient signInClient = GoogleSignIn.getClient(this, signInOption);
        Intent intent = signInClient.getSignInIntent();
        startActivityForResult(intent, RC_SIGN_IN);
    }
    /** Auth code to send to backend server */
    private String mServerAuthCode;
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == RC_SIGN_IN) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            mServerAuthCode = result.getSignInAccount().getServerAuthCode();
        } else {
            String message = result.getStatus().getStatusMessage();
            if (message == null || message.isEmpty()) {
                message = getString(R.string.signin_other_error);
            }
            new AlertDialog.Builder(this).setMessage(message)
                .setNeutralButton(android.R.string.ok, null).show();
        }
      }
    }
  และอัปเดตเป็น
  private void startRequestServerSideAccess() {
      GamesSignInClient gamesSignInClient = PlayGames.getGamesSignInClient(this);
      gamesSignInClient
          .requestServerSideAccess(OAUTH_2_WEB_CLIENT_ID,
           /* forceRefreshToken= */ false, /* additional AuthScope */ scopes)
          .addOnCompleteListener(task -> {
              if (task.isSuccessful()) {
                  AuthResponse authresp = task.getResult();
                  // Send the authorization code as a string and a
                  // list of the granted AuthScopes that were granted by the
                  // user. Exchange for an access token.
                  // Verify the player with Play Games Services REST APIs.
              } else {
                // Authentication code retrieval failed.
              }
        });
  }
  Kotlin
ค้นหารหัสสำหรับชั้นเรียน GoogleSignInOptions
  // ... existing code
  private val RC_SIGN_IN = 9001
  private lateinit var googleSignInClient: GoogleSignInClient
  // Auth code to send to backend server.
  private var mServerAuthCode: String? = null
  private fun startSignInForAuthCode() {
      // Client ID for your backend server.
      val webClientId = getString(R.string.webclient_id)
      val signInOption = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
          .requestServerAuthCode(webClientId)
          .build()
      googleSignInClient = GoogleSignIn.getClient(this, signInOption)
      val intent = googleSignInClient.signInIntent
      startActivityForResult(intent, RC_SIGN_IN)
  }
  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
      super.onActivityResult(requestCode, resultCode, data)
      if (requestCode == RC_SIGN_IN) {
          val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
          if (result.isSuccess) {
              mServerAuthCode = result.signInAccount.serverAuthCode
          } else {
              var message = result.status.statusMessage
              if (message == null || message.isEmpty()) {
                  message = getString(R.string.signin_other_error)
              }
              AlertDialog.Builder(this).setMessage(message)
                  .setNeutralButton(android.R.string.ok, null).show()
            }
        }
  }
  และอัปเดตเป็น
  private void startRequestServerSideAccess() {
  GamesSignInClient gamesSignInClient = PlayGames.getGamesSignInClient(this);
      gamesSignInClient
          .requestServerSideAccess(OAUTH_2_WEB_CLIENT_ID, /* forceRefreshToken= */ false,
          /* additional AuthScope */ scopes)
          .addOnCompleteListener(task -> {
              if (task.isSuccessful()) {
                  AuthResponse authresp = task.getResult();
                  // Send the authorization code as a string and a
                  // list of the granted AuthScopes that were granted by the
                  // user. Exchange for an access token.
                  // Verify the player with Play Games Services REST APIs.
              } else {
                // Authentication code retrieval failed.
              }
        });
  }
  ย้ายข้อมูลจาก GoogleApiClient
สำหรับการผสานรวมที่มีอยู่เดิมที่เก่ากว่า เกมของคุณอาจขึ้นอยู่กับGoogleApiClientรูปแบบ API ของ Play Games Services SDK ซึ่งเลิกใช้งานในช่วงปลายปี 2017
และแทนที่ด้วยไคลเอ็นต์ "แบบไม่มีการเชื่อมต่อ"
หากต้องการย้ายข้อมูล คุณสามารถแทนที่คลาส GoogleApiClient ด้วยคลาสที่เทียบเท่าแบบ "ไม่มีการเชื่อมต่อ"
ตารางต่อไปนี้แสดงการแมปคลาสที่พบบ่อยจากเกมเวอร์ชัน 1 เป็นเกมเวอร์ชัน 2
| เกม v2 (ปัจจุบัน) | เกม v1 (เดิม) | 
|---|---|
| com.google.android.gms.games.AchievementsClient | com.google.android.gms.games.achievement.Achievements | 
| com.google.android.gms.games.LeaderboardsClient | com.google.android.gms.games.leaderboard.Leaderboard | 
| com.google.android.gms.games.SnapshotsClient | com.google.android.gms.games.snapshot.Snapshots | 
| com.google.android.gms.games.PlayerStatsClient | com.google.android.gms.games.stats.PlayerStats | 
| com.google.android.gms.games.PlayersClient | com.google.android.gms.games.Players | 
| com.google.android.gms.games.GamesClientStatusCodes | com.google.android.gms.games.GamesStatusCodes | 
สร้างและเรียกใช้เกม
หากต้องการสร้างและเรียกใช้ใน Android Studio โปรดดูสร้างและเรียกใช้แอป
ทดสอบเกม
ตรวจสอบว่าเกมทำงานได้ตามที่ออกแบบไว้โดยการทดสอบ การทดสอบที่คุณดำเนินการ ขึ้นอยู่กับฟีเจอร์ของเกม
ต่อไปนี้คือรายการการทดสอบที่พบบ่อยซึ่งควรเรียกใช้
ลงชื่อเข้าใช้สำเร็จ
การลงชื่อเข้าใช้โดยอัตโนมัติใช้งานได้ ผู้ใช้ควรลงชื่อเข้าใช้บริการเกมของ Play เมื่อเปิดตัวเกม
ป๊อปอัปต้อนรับจะแสดงขึ้น
ป๊อปอัปต้อนรับตัวอย่าง (คลิกเพื่อขยาย) ข้อความบันทึกที่สำเร็จจะปรากฏขึ้น เรียกใช้คำสั่งต่อไปนี้ในเทอร์มินัล
adb logcat | grep com.google.android.
ตัวอย่างต่อไปนี้แสดงข้อความบันทึกที่สำเร็จ
[
$PlaylogGamesSignInAction$SignInPerformerSource@e1cdecc number=1 name=GAMES_SERVICE_BROKER>], returning true for shouldShowWelcomePopup. [CONTEXT service_id=1 ] 
ตรวจสอบความสอดคล้องของคอมโพเนนต์ UI
ป๊อปอัป ลีดเดอร์บอร์ด และรางวัลพิเศษแสดงอย่างถูกต้องและ สอดคล้องกันในขนาดและการวางแนวหน้าจอต่างๆ ใน อินเทอร์เฟซผู้ใช้ (UI) ของบริการเกมของ Play
ตัวเลือกการออกจากระบบไม่ปรากฏใน UI ของบริการเกมของ Play
ตรวจสอบว่าคุณดึงข้อมูลรหัสผู้เล่นได้สำเร็จ และหากมี ความสามารถฝั่งเซิร์ฟเวอร์ทํางานได้ตามที่คาดไว้
หากเกมใช้การตรวจสอบสิทธิ์ฝั่งเซิร์ฟเวอร์ ให้ทดสอบ
requestServerSideAccessโฟลว์อย่างละเอียด ตรวจสอบว่าเซิร์ฟเวอร์ได้รับรหัสการให้สิทธิ์ และแลกเป็นโทเค็นเพื่อการเข้าถึงได้ ทดสอบทั้งสถานการณ์ที่สำเร็จและไม่สำเร็จสำหรับข้อผิดพลาดเกี่ยวกับเครือข่าย สถานการณ์ที่ไม่ถูกต้องclient ID
หากเกมของคุณใช้ฟีเจอร์ใดฟีเจอร์หนึ่งต่อไปนี้ ให้ทดสอบเพื่อให้แน่ใจว่าฟีเจอร์เหล่านั้นทำงานเหมือนเดิมก่อนการย้ายข้อมูล
- ลีดเดอร์บอร์ด: ส่งคะแนนและดูลีดเดอร์บอร์ด ตรวจสอบว่า การจัดอันดับและการแสดงชื่อและคะแนนของผู้เล่นถูกต้อง
 - รางวัลพิเศษ: ปลดล็อกรางวัลพิเศษและตรวจสอบว่าระบบบันทึกอย่างถูกต้อง และแสดงใน UI ของ Play Games
 - เกมที่บันทึกไว้: หากเกมใช้เกมที่บันทึกไว้ ให้ตรวจสอบว่าการบันทึกและการโหลดความคืบหน้าของเกมทำงานได้อย่างราบรื่น การดำเนินการนี้มีความสำคัญอย่างยิ่งต่อการทดสอบ ในอุปกรณ์หลายเครื่องและหลังการอัปเดตแอป
 
งานหลังการย้ายข้อมูล
ทำตามขั้นตอนต่อไปนี้หลังจากย้ายข้อมูลไปยัง Games v2 แล้ว
เผยแพร่เกม
สร้าง APK และเผยแพร่เกมใน Play Console
- ในเมนู Android Studio ให้เลือก Build > สร้าง Bundle/APK > สร้าง APK
 - เผยแพร่เกมของคุณ ดูข้อมูลเพิ่มเติมได้ที่ เผยแพร่แอปส่วนตัวจาก Play Console