首页 > 解决方案 > Unity 中的 Google Play 游戏服务无法进行身份验证

问题描述

GPG 服务不工作

它显示本地 GPG 窗口,但当它关闭时PlayGamesPlatform.Instance.Authenticate()回调返回NetworkError

在 Google Play 控制台中:创建了“游戏服务”。

在谷歌 API 中:

在统一中:

测试版本使用与 Google Play 上发布的应用程序相同的密钥进行签名,并具有相同的公司名称和产品名称

PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.RequestIdToken()
.Build();

PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();

PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptAlways, ((SignInStatus status) =>
{
        if (status == SignInStatus.Success)
        {
            print( $"Welcome {PlayGamesPlatform.Instance.GetUserDisplayName()}\n");
        }
        else
        {
            print($"Fail:{status}");
        }
}));

在 Unty Console 中调试时,我有

<i>AndroidPlayer(ADB@127.0.0.1:34999)</i> Returning an error code.
 #0 0x443df5a (libunity.so) GetStacktrace(int) 0x25
 #1 0x4e788b6 (libunity.so) DebugStringToFile(DebugStringToFileData const&) 0x169
 #2 0x49875fe (libunity.so) DebugLogHandler::Internal_Log(LogType, LogOption, core::basic_string<char, core::StringStorageDefault<char> >, Object*) 0x65
 #3 0x498754e (libunity.so) DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*) 0xb5

标签: unity3dauthenticationgoogle-oauthgoogle-play-games

解决方案


我在尝试自己寻找答案时遇到了这篇文章,现在我知道答案了,我想我会把它加在这里....这样我下次忘记如何做时无疑可以发现它。正如@CherryCoke 所说,这个问题是由缩小引起的。

解决方案可以在这里找到:https ://github.com/playgameservices/play-games-plugin-for-unity/blob/master/README.md#decreating-apk-size

您有两个选择:关闭缩小或告诉缩小过程在进行缩小时要忽略的内容。

如果你想缩小你的构建(这对我来说很有意义),那么你可以通过在播放器设置的 Android 构建的发布设置区域中选择“自定义 Proguard 文件”来实现。

在此处输入图像描述

添加后,您需要更新指定的 proguard-user.txt 文件。该路径显示在“自定义 proguard 文件”下。

对于 google play 服务,您需要添加的条目可以在以下位置找到:https ://github.com/playgameservices/play-games-plugin-for-unity/blob/master/scripts/proguard.txt


推荐阅读