简体   繁体   中英

Google Play Games Unity SDK cannot create GameServices object

I cannot Login with Google Play Unity Plugin, this code was working before and now it's not working.

PlayGamesPlatform.Activate ();
PlayGamesPlatform.Instance.localUser.Authenticate (success => {
if (success) {
    LoginType = LoginType.Google;
    StartCoroutine( WaitForEmail());

} else {
    Debug.LogError ("Cannot Login with Gmail");
    return;
}
});

i have updated google play services libraries.

在此处输入图片说明

Here is the Adb logcat output :

10-25 19:16:37.399 17469 17488 D GamesUnitySDK: Performing Android initialization of the GPG SDK
10-25 19:16:37.408 17469 17488 I art     : Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.games.multiplayer.ParticipantResult>
10-25 19:16:37.409 17469 17488 I art     : Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.games.multiplayer.ParticipantResult>
10-25 19:16:37.409 17469 17488 E GamesNativeSDK: Can't register class com/google/android/gms/games/multiplayer/ParticipantResult: an exception occurred.
10-25 19:16:37.414 17469 17488 I art     : Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.nearby.connection.AppIdentifier>
10-25 19:16:37.414 17469 17488 I art     : Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.nearby.connection.AppIdentifier>
10-25 19:16:37.414 17469 17488 E GamesNativeSDK: Can't register class com/google/android/gms/nearby/connection/AppIdentifier: an exception occurred.
10-25 19:16:37.415 17469 17488 I art     : Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.nearby.connection.AppMetadata>
10-25 19:16:37.415 17469 17488 I art     : Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.nearby.connection.AppMetadata>
10-25 19:16:37.416 17469 17488 E GamesNativeSDK: Can't register class com/google/android/gms/nearby/connection/AppMetadata: an exception occurred.
10-25 19:16:37.531 17469 17488 I Unity   : Building GPG services, implicitly attempts silent auth
10-25 19:16:37.531 17469 17488 I Unity   :
10-25 19:16:37.531 17469 17488 I Unity   : (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
10-25 19:16:37.531 17469 17488 I Unity   :
10-25 19:16:37.532 17469 17488 E GamesNativeSDK: Could not register one or more required Java classes.
10-25 19:16:37.595 17469 17488 I Unity   : InvalidOperationException: There was an error creating a GameServices object. Check for log errors from GamesNativeSDK
10-25 19:16:37.595 17469 17488 I Unity   :   at GooglePlayGames.Native.PInvoke.GameServicesBuilder.Build (GooglePlayGames.Native.PInvoke.PlatformConfiguration configRef) [0x00000] in <filename unknown>:0
10-25 19:16:37.595 17469 17488 I Unity   :   at GooglePlayGames.Native.NativeClient.InitializeGameServices () [0x00000] in <filename unknown>:0
10-25 19:16:37.595 17469 17488 I Unity   :   at GooglePlayGames.Native.NativeClient.Authenticate (System.Action`1 callback, Boolean silent) [0x00000] in <filename unknown>:0
10-25 19:16:37.595 17469 17488 I Unity   :   at GooglePlayGames.PlayGamesPlatform.Authenticate (System.Action`1 callback, Boolean silent) [0x00000] in <filename unknown>:0
10-25 19:16:37.595 17469 17488 I Unity   :   at GooglePlayGames.PlayGamesPlatform.Authenticate (System.Action`1 callback) [0x00000] in <filename unknown>:0
10-25 19:16:37.595 17469 17488 I Unity   :   at GooglePlayGames.PlayGamesLocalUser.Authenticate (System.Action`1 callback) [0x00000] in <filename unknown>:0
10-25 19:16:37.595 17469 17488 I Unity   :   at Controllers.LoginController.OnClickedOnGmail () [0x00000] in <filename unknown>:0

Thanks.

Based on this Github , The message: InvalidOperationException: There was an error creating a GameServices object. Check for log errors from GamesNativeSDK InvalidOperationException: There was an error creating a GameServices object. Check for log errors from GamesNativeSDK usually means that the Android SDK is too old. You should update the Google Play services, Google Repository, Android Support Library, and Android Support Repository components.

Maybe another reason for that problem is version 8.4.0 is not compatible with the Play service API version 9.8.0

Here are the lists of updated version of Google Play services API .

For more information, just check the Github link above to know the other solutions for this kind of error.

This helped me.

https://github.com/playgameservices/play-games-plugin-for-unity/issues/2217#issuecomment-417619382

Can confirm this works:

open template-AndroidManifest.txt
"\ APP_ID" to "\u003__APP_ID__"
setup GPGS from Unity (press Window/Google Play Services/Setup)

True, after the correction, I received the error "Authentification failed" .

But it was a problem with SHA-1.It was decided when I did:

keytool -exportcert -keystore user.keystore -list -v

And put the correct SHA-1 in https://console.developers.google.com/apis/credentials in the application settings.

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