android - Unity - Google Play 游戏服务不工作?

标签 android unity-game-engine google-play-games

好的,所以我之前在很多游戏中实现了 GPGS 并且成功了,但现在它似乎不起作用。我加载了游戏,但它什么也做不了,没有登录对话框或任何东西。这是我用来登录的代码:

using UnityEngine;
using System.Collections;
using UnityEngine.SocialPlatforms;
using GooglePlayGames;
using GooglePlayGames.BasicApi;

public class GpgsStart : MonoBehaviour {


void Start () {
        PlayGamesPlatform.Activate ();
        Social.localUser.Authenticate((bool success) => {
            if(!success)
            {
                PlayerPrefs.SetString("SignIn", "false");
                Debug.Log("Couldn't Sign In");
            }
        });
    }

    // Update is called once per frame
    void Update () {

    }
}

我真的不明白为什么它不起作用,并且想知道我是否犯了一个愚蠢的错误或错过了什么。任何人都知道是什么导致了我的问题?

非常感谢任何帮助,谢谢。

这是 logcat 输出:

I/Unity   ( 9861): InvalidOperationException: There was an error creating a Game
Services object. Check for log errors from GamesNativeSDK
I/Unity   ( 9861):   at GooglePlayGames.Native.PInvoke.GameServicesBuilder.Build
 (GooglePlayGames.Native.PInvoke.PlatformConfiguration configRef) [0x00000] in <
filename unknown>:0
I/Unity   ( 9861):   at GooglePlayGames.Native.NativeClient.InitializeGameServic
es () [0x00000] in <filename unknown>:0
I/Unity   ( 9861):   at GooglePlayGames.Native.NativeClient.Authenticate (System
.Action`1 callback, Boolean silent) [0x00000] in <filename unknown>:0
I/Unity   ( 9861):   at GooglePlayGames.PlayGamesPlatform.Authenticate (System.A
ction`1 callback, Boolean silent) [0x00000] in <filename unknown>:0
I/Unity   ( 9861):   at GooglePlayGames.PlayGamesPlatform.Authenticate (System.A
ction`1 callback) [0x00000] in <filename unknown>:0
I/Unity   ( 9861):   at GooglePlayGames.PlayGamesLocalUser.Authenticate (System.
Action`1 callback) [0x00000] in <filename unknown>:0
I/Unity   ( 9861):   at GpgsStart.Start () [0x00000] in <filename unknown>:0
I/Unity   ( 9861):
I/Unity   ( 9861): (Filename:  Line: -1)
I/Unity   ( 9861):
V/WindowManager(  451): Window{422852e8 u0 Keyguard}mOrientationRequetedFromKeyg
uard=false

最佳答案

这很可能是由旧版本的 google play 服务客户端库引起的。如果缺少 java 类,游戏 SDK 将无法正确初始化。您可以通过在日志的前面查找类未找到错误来确认这一点。

要解决此问题,请使用 SDK 管理器将播放服务 SDK 更新到最新版本。在 Unity 中,这是窗口 > Google Play 游戏 > 下载 > Google Play 游戏 SDK (Android)...

然后再次运行 Play Games Setup,Window > Google Play Games > Setup > Android Setup...这会将更新客户端库复制到您的 Unity 项目中。

关于android - Unity - Google Play 游戏服务不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34417732/

相关文章:

java - 应用程序只是强制关闭并停止工作,为什么?

android - 如何强制 sqlite 将日志文件合并到主数据库中?

java - 如何使用 FileReader 引用我的原始 txt 文件?

unity-game-engine - UnityWebRequest 改为 https

c# - Adcolony 路径共享违规

android - 使用 Google Play 游戏服务仅显示社交排行榜

android - 未获得 Kindle Fire Android 的应用内购买回调

php - 如何使用 PHP 验证我的 'third party server' 上的 GKLocalPlayer?

unity-game-engine - unity 为移动物体烘焙光

android - 安装 BaseGameUtils 后的奇怪问题