简体   繁体   中英

Unity - Google Play Games Services not working?

Okay, so I have implemented GPGS into many games before with success, but now it doesnt seem to work. I load the game and it just wont do anything, no sign in dialog or anything. This is the code i use to sign in:

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 () {

    }
}

I really cant see why it is not working, and am wondering if there is a silly mistake i have made or something i missed out. Anyone know what could be causing my probem?

Any help is greatly appreciated, thanks.

This is the logcat output:

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

Most likely this is caused by an older version of the google play services client library. If there are missing java classes, the Games SDK will not initialize correctly. You can confirm this by looking for class not found errors earlier in the log.

To fix this, update the play services SDK to the latest version using the SDK Manager. Within Unity, this is Window > Google Play Games > Downloads > Google Play Games SDK (Android)...

Then run the Play Games Setup again, Window > Google Play Games > Setup > Android Setup... This will copy the update client library into your Unity project.

This is generally by the missing of .aar file from your project. For play game services there are some .aar files which are needed. Cross check this .aar files with yours files

  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

Version of this .aar files may be differ, but this thing work for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM