The second Android 11 Developer Preview is now available, test it out and share your feedback.

Support game save

Saving games is a best practice for all Google Play Instant games and is a requirement for Instant play games. Players of Google Play Instant games trust Google to save games they play regularly and clean up games they have stopped playing. The Android operating system will also clean up games if the user is very low on storage space. Make sure that the player's game state can live beyond the instant APK. Players don't like to see their game progress disappear, seemingly at random.

Implement the library

The recommended way to save game progress is to implement the Google Play Games Services saved games feature.

This process is straightforward for Instant play games. Most users launching your game from the Google Play Games app already have a Google Play Games Services profile. Since most users are automatically signed-in, the saved games API has the required account information to save games for the user.

Size impact of the library

The size impact of the Google Play Games Services library depends on whether the game engine runs on Java, Native, or Unity.

Java

The size impact should be fairly negligible since ProGuard has good insight into which classes are actually used.

Unity

If you want to integrate game save into your Unity game, you can use the official Google Play Game Services plugin. The size impact will be minimal, around 200kb if the ProGuard recommendations are used.

Native

If you want to integrate game save with a game built on the NDK, use the Native Play Games Services SDK.

Use the general ProGuard configuration below to strip out most of the Java code included by the library. Using this config, you should be able to implement Play Games Services sign-in and game save while only adding about 250KB to the APK.

# The native PGS library wraps the Java PGS SDK using reflection.
-dontobfuscate
-keeppackagenames

# Needed for callbacks.
-keepclasseswithmembernames,includedescriptorclasses class * {
    native <methods>;
}

# Needed for helper libraries.
-keep class com.google.example.games.juihelper.** {
  public protected *;
}
-keep class com.sample.helper.** {
  public protected *;
}

# Needed for GoogleApiClient and auth stuff.
-keep class com.google.android.gms.common.api.** {
  public protected *;
}

# Keep all of the "nearby" library, which is needed by the native PGS library
# at runtime (though deprecated).
-keep class com.google.android.gms.nearby.** {
  public protected *;
}

# Keep all of the public PGS APIs.
-keep class com.google.android.gms.games.** {
  public protected *;
}