- Home /
play-games-plugin-for-unity Authentication issue
I have downloaded the google play service form https://github.com/playgameservices/play-games-plugin-for-unity. i have followed the tutorial on github and implemented it. When i click on log in button nothing happened. Here is the code.
using UnityEngine;
using System.Collections;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
public class testGPGMenu : MonoBehaviour
{
public GUISkin skin;
public int incrementalCount = 5;
//leaderboard strings
private string leaderboard = "C----------------g";
//achievement strings
private string achievement = "C----------------Q";
private string incremental = "C----------------g";
// Use this for initialization
void Start()
{
PlayGamesPlatform.Activate();
}
// Update is called once per frame
public void OnGUI()
{
GUI.skin = skin;
skin.button.fixedWidth = Screen.width - 25;
skin.textField.fixedWidth = Screen.width - 25;
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
GUILayout.BeginVertical("box");
GUILayout.Label("Official Google Play Games Services");
GUILayout.Space(20);
//Share Status
if (GUILayout.Button("Log In"))
{
Social.localUser.Authenticate((bool success) =>
{
if (success)
{
Debug.Log("You've successfully logged in");
}
else
{
Debug.Log("Login failed for some reason");
}
});
}
GUILayout.Space(20);
//Achievement
if (GUILayout.Button("Unlock Achievement"))
{
if (Social.localUser.authenticated)
{
Social.ReportProgress(achievement, 100.0f, (bool success) =>
{
if (success)
{
Debug.Log("You've successfully logged in");
}
else
{
Debug.Log("Login failed for some reason");
}
});
}
}
GUILayout.Space(20);
//Incremental Achievement
if (GUILayout.Button("Press " + incrementalCount + "more times to unlock incremental acheivment"))
{
if (Social.localUser.authenticated)
{
((PlayGamesPlatform)Social.Active).IncrementAchievement(incremental, 5, (bool success) =>
{
//The achievement unlocked successfully
});
}
}
GUILayout.Space(20);
//Leaderboard
if (GUILayout.Button("Post your 5000 points to the leaderboard"))
{
if (Social.localUser.authenticated)
{
Social.ReportScore(5000, leaderboard, (bool success) =>
{
if (success)
{
((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(leaderboard);
}
else
{
//Debug.Log("Login failed for some reason");
}
});
}
}
GUILayout.Space(20);
// Show Leaderboard
if (GUILayout.Button("Show Leaderboard"))
{
Social.ShowLeaderboardUI();
}
GUILayout.Space(20);
//Show Specific Leaderboard
if (GUILayout.Button("Show Specific Leaderboard"))
{
((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(leaderboard);
}
GUILayout.Space(20);
//Show Achievments
if (GUILayout.Button("Show Achievments"))
{
Social.ShowAchievementsUI();
}
GUILayout.Space(20);
//Sign Out
if (GUILayout.Button("Sign Out"))
{
((PlayGamesPlatform)Social.Active).SignOut();
}
GUILayout.EndVertical();
GUILayout.EndArea();
}
}
Here is what i get in logcat 07-22 15:43:00.678: I/Unity(1222): NullReferenceException: Object reference not set to an instance of an object 07-22 15:43:00.678: I/Unity(1222): at GooglePlayGames.Android.AndroidClient+c_AnonStorey0.<>m_1 () [0x00000] in :0 07-22 15:43:00.678: I/Unity(1222): at UnityEngine.AndroidJavaRunnableProxy.run () [0x00000] in :0 07-22 15:43:00.678: I/Unity(1222): at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 07-22 15:43:00.678: I/Unity(1222): Rethrow as TargetInvocationException: UnityEngine.AndroidJavaRunnableProxy.run() 07-22 15:43:00.678: I/Unity(1222): at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x00000] in :0 07-22 15:43:00.678: I/Unity(1222): at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, UnityEngine.AndroidJavaObject[] javaArgs) [0x00000] in :0 07-22 15:43:00.678: I/Unity(1222): at UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, IntPtr jmethodName, IntPtr jargs) [0x00000] in :0
Facing similar problems here. Did you manage to solve these?
Answer by GDesmoulins · Oct 02, 2015 at 12:26 PM
Hello Guys,
After 2 days of tests with Authentification problems, (ERROR_NOT_AUTHORIZED) I spotted my mistake : "PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder() .EnableSavedGames() .Build(); " I wrotted : ".EnableSavedGames()" but my game don't use it in Google Play interface, so the error occured ! Simply removing it (for my part), and let's rock n roll !
Answer by malekbakeer · Nov 21, 2014 at 04:50 AM
This Happened to me yesterday... u need to go to developer console then go to testing and activate Beta & Alpha testers... that simple
I faced similar problem, but it is not solved when I activated alfa and beta test :(
Answer by fahadshafique · Nov 18, 2016 at 08:16 AM
i had the same issue...enable alpha testing from the developer console and add your mobile device email id to the console for testing
Your answer
![](https://koobas.hobune.stream/wayback/20220613154749im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Google Play Game Services plugin problem 4 Answers
Build Error for android 1 Answer
Google Play Services Offline Use 0 Answers
Error text from google game services 0 Answers