Problem with Google Play Services (authentication, leaderboards)

Hi.
I’ve been having some problems with the Google Play Services plugin I downloaded from github. The problem is that it won’t sign in, show leaderboards, achivements or anything.

This is the script I have at the main menu of my game:

using UnityEngine;
using System.Collections;

using GooglePlayGames;
using UnityEngine.SocialPlatforms;

public class GooglePS : MonoBehaviour {

	public void Awake () {

		Social.localUser.Authenticate((bool success) => {
			if (success) {
				Debug.Log("You've successfully logged in");
			} else {
				Debug.Log("Login failed for some reason");
			}
		});		
	}

	public void LeaderBoard () {

		PlayGamesPlatform.Instance.ShowLeaderboardUI("CgkIvavq-e8fEAIQAA");

	}

}

Inside of the editor it gives me the message that the sign-in was successful, but when I build it to my android phone, nothing happens… I thought that maybe the Awake function wasn’t called, so I made a button that calls it, still nothing happens… (Same with the leaderboards). It doesn’t give me any errors inside the editor either, so I can’t figure out what is wrong…

I searched for a solution on Google, but couldn’t find anything that helped. I tried altering the android manifest, importing older versions of the plugin, checked to see if the SDK was up to date (which it was), but again, nothing seemed to fix my problem.

The only “error” I get is a warning when I perform the Android setup with the plugin which says:

The verson of your copy of the Google Play Services Library Project could not be determined Please make sure it is at least version 6111000. Continue?

And even after that, it gives me a message that says the setup was successful. I can’t for the life of me figure out what’s wrong, so any help is greatly appreciated.
Thanks in advance!

Have you tried adding your account as a tester in in the Google Play dev console? If you haven’t, you wont be able to test Google Play Services for your app.

I’ve managed to fix the problem now! First I downloaded the new version of the plugin (0.9.15). First it didn’t help, but then I added some new lines to my script. Now it looks like this;

using UnityEngine;
using System.Collections;

using GooglePlayGames;
using UnityEngine.SocialPlatforms;
using GooglePlayGames.BasicApi;

using GoogleMobileAds.Api;

public class BannerAd : MonoBehaviour {

	public void Awake () {

		Social.localUser.Authenticate((bool success) => {
			if (success) {
				Debug.Log("You've successfully logged in");
			} else {
				Debug.Log("Login failed for some reason");
			}
		});

		PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
			
			.Build();
		
		PlayGamesPlatform.InitializeInstance(config);
		// recommended for debugging:
		PlayGamesPlatform.DebugLogEnabled = true;
		// Activate the Google Play Games platform
		PlayGamesPlatform.Activate();
		
	}

	public void LeaderBoard () {

		PlayGamesPlatform.Instance.ShowLeaderboardUI("CgkIvavq-e8fEAIQAA");

	}

}

It still won’t log in automatically when the game is started, but I’ve attached the Awake function to a UI-button, so when the button is pressed, the Google sign-in UI shows up.
Hope this helps anyone that encounters the same problem.

I’m using Google Play games plugin for Unity from GitHub.

using following code

PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();

      PlayGamesPlatform.InitializeInstance(config);
      // recommended for debugging:
      PlayGamesPlatform.DebugLogEnabled =true;
      // Activate the Google Play Games platform
      PlayGamesPlatform.Activate();


if(GUI.Button(signInRect,"signin"))
			{
				Social.localUser.Authenticate((bool success) => {
					// handle success or failure
					if(success)
					{
						print ("Login true");

					}
					else
						print ("Google Login failed");
				});

			}

Now when I test it on my device Google Play Pops Up and it shows me google accounts from which I want to login when I select an account then after few seconds it get a message on console that

[Play Games Plugin DLL] Debug :
Invoking user callback on game thread

Google Login failed

Please help me how I can resolve this. Thanks

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

void Start()
{
PlayGamesPlatform.Activate ();
}

void Update()
{
if(GUI.Button(signInRect,"signin"))
             {
                 Social.localUser.Authenticate((bool success) => {
                     // handle success or failure
                     if(success)
                     {
                         print ("Login true");
 
                     }
                     else
                         print ("Google Login failed");
                 });
 
             }
}

should work with that! Must include using UnityEngine.SocialPlatforms; at start whenever calling it.

Hi,

i am also at same issue if you have fix this, please help me how can fix this.

Thanks
Ram

This is the code i used for google services log in , the play services window pops up but it doesnt login into a google account plz help ( added the emailID in tester).

using UnityEngine;
using System.Collections;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
public class GooglePlay : MonoBehaviour
{
#region PUBLIC_VAR
public string leaderboard;
#endregion

#region DEFAULT_UNITY_CALLBACKS
void Start ()
{
	
	PlayGamesPlatform.DebugLogEnabled = true;

	PlayGamesPlatform.Activate ();
}
#endregion

#region BUTTON_CALLBACKS

public void LogIn ()
{
	Social.localUser.Authenticate ((bool success) =>
		{
			if (success) {
				Debug.Log ("Login Sucess");
			} else {
				Debug.Log ("Login failed");
			}
		});
}

public void OnShowLeaderBoard ()
{
	
	((PlayGamesPlatform)Social.Active).ShowLeaderboardUI (leaderboard); // Show current (Active) leaderboard
}

public void OnAddScoreToLeaderBorad ()
{
	if (Social.localUser.authenticated) {
		Social.ReportScore (100, leaderboard, (bool success) =>
			{
				if (success) {
					Debug.Log ("Update Score Success");

				} else {
					Debug.Log ("Update Score Fail");
				}
			});
	}
}

public void OnLogOut ()
{
	((PlayGamesPlatform)Social.Active).SignOut ();
}
#endregion

}