- Home /
Google Play Game Services not working in Unity
I created a game using Unity and now I want to add Play Services in my game. I have uploaded the game on the Google Play Store from the Console, downloaded the play services plugin from GitHub, added it in my Unity project, installed Google Play Services tools from the SDK Manager, created the achievements and the leaderboard and copied the resources to Unity. I even copied the SHA-1 from the Upload Certificate to the Google API credentials. In short, I did every solution I could find on Google. The problem is...
private void SignIn()
{
Social.localUser.Authenticate((bool success) =>
{
if (success)
{
Destroy(testObject);
}
else
{
Destroy(testObject2);
}
});
}
None of these objects are destroyed. Thanks in advance.
Text is better than a screenshot. Also, where are you calling SignIn()
?
It doesn't work on the Editor, or on Android?
Answer by TusharVaid30 · Feb 10, 2019 at 09:58 AM
I found the solution. Go to your Publishing Settings tab in the Player Settings. and set the options like this.....
Then open the proguard-user.txt file and type in this....
-keep class com.google.games.** { _; }
-keep interface com.google.games._* { *; }
Save it and it will surely work.
Hey, are those lines supposed to be exactly like that? with the - at the line start? I'm facing the same issue, ticking the proguard option generated two proguard-user.txt files, I pasted both lines in both of the files and saved, but now I'm stuck with build errors:
No type signature, but name is not <fields> or *
Thanks a lot! You are really a genius! The big problem is that in the official Google Play Services documentation there is no solution to this problem. Can you please explain how this works?
Hello. This works but after showing "Connecting to Google play games", it disconnects and doesn't sign in. What can I do please?
This is the right approach, but it didn't work for me (Unity 2020.1.3f1). Adding the following to the proguard-user.txt file solved the issue for me:
-keep class com.google.games.** { *; }
-keep interface com.google.games.** { *; }
-keep class com.google.unity.** { *; }
-keep class com.google.android.gms.games.multiplayer.** { *; }
-keep class com.google.android.gms.games.leaderboard.** { *; }
-keep class com.google.android.gms.games.snapshot.** { *; }
-keep class com.google.android.gms.games.achievement.** { *; }
-keep class com.google.android.gms.games.event.** { *; }
-keep class com.google.android.gms.games.stats.** { *; }
-keep class com.google.android.gms.games.video.** { *; }
-keep class com.google.android.gms.games.* { *; }
-keep class com.google.android.gms.common.api.ResultCallback { *; }
-keep class com.google.android.gms.signin.** { *; }
-keep class com.google.android.gms.dynamic.** { *; }
-keep class com.google.android.gms.dynamite.** { *; }
-keep class com.google.android.gms.tasks.** { *; }
-keep class com.google.android.gms.security.** { *; }
-keep class com.google.android.gms.base.** { *; }
-keep class com.google.android.gms.actions.** { *; }
-keep class com.google.games.bridge.** { *; }
-keep class com.google.android.gms.common.ConnectionResult { *; }
-keep class com.google.android.gms.common.GooglePlayServicesUtil { *; }
-keep class com.google.android.gms.common.api.** { *; }
-keep class com.google.android.gms.common.data.DataBufferUtils { *; }
-keep class com.google.android.gms.games.quest.** { *; }
-keep class com.google.android.gms.nearby.** { *; }
-dontobfuscate
Thank you very much! When I changed the values of Release and Debug to None, it started to work the sign in on Google Play Games. You really helped me! Thanks!
Answer by mhhk88 · Jun 07, 2019 at 07:11 AM
@TusharVaid30 I don't know how to thank you for your solution. It fixed my problem which has harassed me for the last 10 days. God bless you !!!!!!!
@mhhk88 You're welcome. I am glad it worked out. Good Luck with your project.
Same for me... he is lifesaver... let's give him a cookie !
Answer by Chik3r · Feb 09, 2019 at 06:32 PM
For Google Play Games to work on Android, you have to first configurate and activate PlayGames. Here's how you do it:
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
PlayGamesPlatform.DebugLogEnabled = true;
And then you sign in.
How it would look in the start method:
void Start() {
#if UNITY_ANDROID // Only run on android, because it's not needed for iOS
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
PlayGamesPlatform.DebugLogEnabled = true;
#endif
SignIn();
}
private void SignIn()
{
Social.localUser.Authenticate((bool success) =>
{
if (success)
{
Destroy(testObject);
}
else
{
Destroy(testObject2);
}
});
}
I have the same problem and I found what I did wrong. If you use the plugin, you need to use PlayGamesPlatform.Instance namespace code other than the Social. namespace code. Or the Play Games login won't even pop, yet it does pop if you check Development Build which would be confusing. Hope this would save time for those who come after me
If you use the plugin on github, change this line
Social.localUser.Authenticate((bool success) =>
to
PlayGamesPlatform.Instance.localUser.Authenticate((bool success) =>
Your answer
Follow this Question
Related Questions
Unity Google Play Service Plugin Social.localUser.Authenticate(…) App Crash 1 Answer
Android - Error building Player: CommandInvokationFailure: Failed to re-package resources 0 Answers
Signing into Google Play Game Services Crashes App 0 Answers
Problem with Google Play Game Services: Invalid Classname 1 Answer
Google play authentication failed after adding keystore 0 Answers