מעבר ל-Play Games Services v2 (Java או Kotlin)

במאמר הזה מוסבר איך להעביר משחקים קיימים מ-games v1 SDK ל-games v2 SDK.

לפני שמתחילים

אתם יכולים להשתמש בכל סביבת פיתוח משולבת (IDE) שאתם מעדיפים, כמו Android Studio, כדי להעביר את המשחק. לפני שמעבירים את הנתונים לגרסה 2 של Games, צריך לבצע את השלבים הבאים:

עדכון יחסי התלות

  1. בקובץ build.gradle של המודול, מחפשים את השורה הזו בהגדרות התלויות ברמת המודול.

    implementation "com.google.android.gms:play-services-games-v1:+"

    מחליפים אותו בקוד הבא:

    implementation "com.google.android.gms:play-services-games-v2:version"

    מחליפים את version בגרסה העדכנית ביותר של ערכת ה-SDK למשחקים.

  2. אחרי שמעדכנים את התלות, חשוב לוודא שמשלימים את כל השלבים במאמר הזה.

הגדרת מזהה הפרויקט

כדי להוסיף את מזהה הפרויקט של Play Games Services SDK לאפליקציה, מבצעים את השלבים הבאים:

  1. בקובץ 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/game_services_project_id באמצעות מזהה הפרויקט של שירותי המשחקים של המשחק כערך. מזהה הפרויקט של Games Services מופיע מתחת לשם המשחק בדף הגדרה ב-Google Play Console.

  2. בקובץ 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'

מחליפים את המחלקה 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 בגרסה Games v2. מחליפים את קוד ה-API‏ GoogleSignIn ב-API‏ GamesSignInClient, כמו בדוגמה הבאה.

כדי לבקש אסימון גישה בצד השרת, משתמשים ב-method‏ 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 Games Services מהמשחק. אם המשתמש בוחר לא להיכנס כשהמשחק מופעל, ממשיכים להציג לחצן עם הסמל של שירותי המשחקים של 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 {
        // Disable your integration with Play Games Services or 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
        }
    }
}

עדכון שמות ושיטות של מחלקות לקוח

כשעוברים לגרסה 2 של Games, השיטות שמשמשות לקבלת שמות מחלקות הלקוח שונות. במקום השיטות Games.getxxxClient(), צריך להשתמש בשיטות התואמות PlayGames.getxxxClient().

לדוגמה, במקום השיטה Games.getLeaderboardsClient(), צריך להשתמש ב-PlayGames.getLeaderboardsClient() עבור LeaderboardsClient.

צריך להסיר את כל הקוד שקשור למחלקות GamesClient ו-GamesMetadataClient, כי אין לנו מחלקות חלופיות בגרסה 2 של Games.

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.

עדכון של מחלקות הגישה בצד השרת

כדי לבקש אסימון גישה בצד השרת, משתמשים ב-method‏ GamesSignInClient.requestServerSideAccess() במקום ב-method‏ 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 של משחקים:

משחקים גרסה 2 (נוכחית) משחקים גרסה 1 (דור קודם)
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

איך בונים ומריצים את המשחק

כדי לבצע build ולהריץ ב-Android Studio, אפשר לעיין במאמר בנושא Build והרצה של האפליקציה.

בדיקת המשחק

כדי לוודא שהמשחק פועל כמו שתכננתם, כדאי לבדוק אותו. הבדיקות שתבצעו תלויות בתכונות של המשחק.

ריכזנו כאן רשימה של בדיקות נפוצות שכדאי להריץ.

  1. הכניסה בוצעה בהצלחה.

    1. הכניסה האוטומטית פועלת. המשתמש צריך להיות מחובר לשירותי המשחקים של Play כשהמשחק מופעל.

    2. מוצג חלון קופץ עם הודעת הפתיחה.

      דוגמה לחלון קופץ של הודעת ברוכים הבאים.
      דוגמה לחלון קופץ של הודעת פתיחה (לחיצה להגדלה).

    3. יוצגו הודעות יומן מוצלחות. מריצים את הפקודה הבאה במסוף:

      adb logcat | grep com.google.android.

      בדוגמה הבאה מוצגת הודעה ביומן שמעידה על הצלחה:

      [$PlaylogGamesSignInAction$SignInPerformerSource@e1cdecc
      number=1 name=GAMES_SERVICE_BROKER>], returning true for shouldShowWelcomePopup.
      [CONTEXT service_id=1 ]
  2. מוודאים שיש עקביות ברכיבי ממשק המשתמש.

    1. הפריטים הקופצים, לוחות הלידרבורד וההישגים מוצגים בצורה נכונה ועקבית בגדלים ובכיוונים שונים של מסכים בממשק המשתמש של Play Games Services.

    2. אפשרות היציאה מהחשבון לא מוצגת בממשק המשתמש של שירותי המשחקים של Play.

    3. מוודאים שאפשר לאחזר את מזהה השחקן, ואם רלוונטי, שהיכולות בצד השרת פועלות כמצופה.

    4. אם המשחק משתמש באימות בצד השרת, חשוב לבדוק היטב את תהליך requestServerSideAccess. מוודאים שהשרת מקבל את קוד ההרשאה ויכול להחליף אותו באסימון גישה. בודקים תרחישים של הצלחה ושל כשל בשגיאות רשת, תרחישים לא חוקיים של client ID.

אם המשחק שלכם השתמש באחת מהתכונות הבאות, כדאי לבדוק אותן כדי לוודא שהן פועלות כמו לפני ההעברה:

  • לוחות לידרבורד: שליחת ניקוד וצפייה בלוחות לידרבורד. בודקים את הדירוג הנכון ואת השמות והניקוד של השחקנים.
  • הישגים: ביטול נעילה של הישגים ואימות שהם נרשמים ומוצגים בצורה נכונה בממשק המשתמש של Play Games.
  • משחקים שמורים: אם המשחק משתמש במשחקים שמורים, צריך לוודא שהשמירה והטעינה של ההתקדמות במשחק פועלות בצורה חלקה. חשוב במיוחד לבדוק את זה במכשירים שונים ואחרי עדכוני אפליקציות.

משימות אחרי ההעברה

אחרי המעבר לגרסה 2 של משחקים, צריך לבצע את השלבים הבאים.

פרסום המשחק

יוצרים את קובצי ה-APK ומפרסמים את המשחק ב-Play Console.

  1. בתפריט של Android Studio, בוחרים באפשרות Build > Build Bundles(s) / APK(s) > Build APK(s).
  2. מפרסמים את המשחק. מידע נוסף זמין במאמר בנושא פרסום אפליקציות פרטיות מ-Play Console.