unity3d - Unity 中的 Google Play 游戏服务无法进行身份验证
问题描述
GPG 服务不工作
它显示本地 GPG 窗口,但当它关闭时PlayGamesPlatform.Instance.Authenticate()
回调返回NetworkError
在 Google Play 控制台中:创建了“游戏服务”。
在“游戏详情”部分,添加了描述 512x512 和 1024x500 图标。
在“链接的应用程序”部分,添加了一个安卓应用程序并完成了身份验证(自动创建了 OAuth 2.0 密钥)
在“成就”部分,创建了一个带有描述和 512x512 图标的成就。
在“测试”部分添加了一个用于测试的 gmail 帐户
在“发布”部分中,单击发布。
在谷歌 API 中:
已激活 Google Drive API 和 Google Play Android 开发者 API(无需创建任何密钥)
在 Android 的 OAuth 密钥和“发布管理”>“应用唱歌”>“应用签名证书”中检查了 SHA-1</p>
在统一中:
从https://github.com/playgameservices/play-games-plugin-for-unity下载最新版本
在窗口> Google Play 游戏> 设置> Android 设置中,使用“获取资源”链接从 Google Play 控制台的“成就”部分复制 xml 格式文本,ClientID 格式为 123456789123456-ffffffffffffffffffffffff.apps.googleusercontent.com
测试版本使用与 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
解决方案
我在尝试自己寻找答案时遇到了这篇文章,现在我知道答案了,我想我会把它加在这里....这样我下次忘记如何做时无疑可以发现它。正如@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
推荐阅读
- windowsiot - DragonBoard 410c 创建自定义 Windows 10 IoT Core 映像
- php - php memcached 请求之间的持久性
- apache-spark-sql - SQL Spark对多列求和和分组
- android - 如何将谷歌地图活动与导航抽屉联系起来?
- vba - 添加到 Word 文档中的每个特定单词
- javascript - 为什么在winOrNot函数中输入参数(false)时代码不会隐藏html div?
- java - DefaultJmsListenerContainerFactory - 并发 - 每个队列的线程数在什么时候开始增加?
- security - 获取 java.io.IOException:密钥库被篡改,或生成证书时密码不正确
- reactjs - 带有样式组件的条件样式
- javascript - 我已将反应组件方法的类型更改为异步及其在出错后