支持 Google Play 游戏服务

所有免安装 Play 游戏都必须支持 使用 Google Play 游戏服务登录。使用 Google Play 游戏服务 提供一致的玩家 ID,可用于恢复已保存的进度 管理基础架构。

库对应用程序大小的影响

Google Play 游戏服务库的大小影响取决于 游戏引擎在 Unity、Java 或 Native 上运行。

Java

对应用大小的影响微乎其微,因为 ProGuard 只会收到 具体使用了哪些类

Unity

您可以使用 官方 Google Play 游戏服务插件。 如果您使用 ProGuard 建议,则大小影响约为 200 KB。

原生

您可以使用 原生 Play 游戏服务 SDK

使用下面的常规 ProGuard 配置可删除该库所包含的大多数 Java 代码。你可以实现 Play 游戏服务 登录和保存游戏 250 KB。

# 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 *;
}