【问题标题】:Unity - Google Play Games Services not working?Unity - Google Play 游戏服务不起作用?
【发布时间】:2015-12-22 14:09:43
【问题描述】:

好的,所以我之前已经成功地将 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

【问题讨论】:

  • 你的日志猫说什么?手机设置可能有问题?
  • 我拥有的所有其他应用程序都可以使用,这与应用程序有关。我不知道如何用 Unity 登录,你能告诉我吗?如果这有什么不同,我目前正在更新 SDK 管理器中的 GPGS rev。
  • 基本上转到终端/命令提示符并输入“adb logcat”,或者如果这不起作用,请转到您的 Android SDK 文件夹 > 平台工具,然后输入“./adb logcat”。它将实时显示您手机中的所有内容,包括您的 GPGS 应用程序的任何例外情况。
  • 在命令提示符中显示“''adb' 未被识别为内部或外部命令、可运行程序或批处理文件。”,
  • 好的,我添加了 logcat 输出。

标签: android unity3d google-play-games


【解决方案1】:

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

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

然后再次运行 Play 游戏设置,窗口 > Google Play 游戏 > 设置 > Android 设置...这会将更新客户端库复制到您的 Unity 项目中。

【讨论】:

    【解决方案2】:

    这通常是由于您的项目中缺少 .aar 文件。 对于玩游戏服务,需要一些 .aar 文件。 用你的文件交叉检查这个 .aar 文件

    1. play-services-auth-9.2.1
    2. play-services-auth-base-9.2.1
    3. play-services-base-9.2.1
    4. play-services-basement-9.2.1
    5. play-services-drive-9.2.1
    6. play-services-games-9.2.1
    7. play-services-nearby-9.2.1
    8. play-services-tasks-9.2.1
    9. support-v4-23.4.0

    这个 .aar 文件的版本可能不同,但这对我有用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-31
      • 1970-01-01
      • 2014-02-02
      • 1970-01-01
      • 1970-01-01
      • 2014-09-17
      相关资源
      最近更新 更多