I can't get google play services to work (leaderboard)

Hi,

I’m trying to add leaderboard to my google play game, to do so I have :

  1. Downloaded the plugin from here : GitHub - playgameservices/play-games-plugin-for-unity: Google Play Games plugin for Unity
  2. Uploaded my game here : Google Play for business | Launch & monetize your apps | Google Play Console after filling the required data and creating keystroke etc…
  3. added a new game to game services and created leaderboard inside, then copied the resources to my android setup (in unity)
  4. published the game as alpha and added my account as alpha tester
  5. downloaded the game from play store on my phone
    now whenever I test it, it just show the login modal for few seconds (sometimes it asks me to pick the email) then it disappears and nothing happens after that, can any one help please ?
    here is my code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

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

public class LeaderBoardManager : MonoBehaviour {

    public static LeaderBoardManager instance;

    void Awake()
    {
        if (instance == null)
            instance = this;
    }

    // Use this for initialization
    // Use this for initialization
    void Start()
    {
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
        // enables saving game progress.
        .EnableSavedGames()
        // requests the email address of the player be available.
        // Will bring up a prompt for consent.
        .RequestEmail()
        // requests a server auth code be generated so it can be passed to an
        //  associated back end server application and exchanged for an OAuth token.
        .RequestServerAuthCode(false)
        // requests an ID token be generated.  This OAuth token can be used to
        //  identify the player to other services such as Firebase.
        .RequestIdToken()
        .Build();

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


    // Update is called once per frame
    void Update () {
      
    }

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

    public void AddNewScore()
    {
        Social.ReportScore(ScoreManager.instance.score, LeaderBoard.leaderboard_scores, (bool success) => {

        });
    }

    public void ShowLeaderBoard()
    {
        PlayGamesPlatform.Instance.ShowLeaderboardUI(LeaderBoard.leaderboard_scores);
    }
}

I’m calling the method ShowLeaderBoard when a user clicks on a certain button (I know I must check if the user is logged in first, but I’m calling sign in in the start method, i tried both methods but none of them is working)

anyone can help please ?

EDIT : I found this error in the logs:
Application ID [my_app_id] is not associated with package [my_package]. Check the application ID in your manifest.

I have followed every single tutorial I found on the net, always the same problem, the best I could get is being able to login but the leaderboard doesn’t show please help !

The logs when login works but not the leaderboard:

The problem was from the plugin, here is the fix : Leaderboard does not display · Issue #1940 · playgameservices/play-games-plugin-for-unity · GitHub

i am also trying to work on leaderboard i failed in all attempts. can you please guide me how to do work on leaderboard?

There’s one thing worth trying: in case you’re using two different Google accounts to develop and to test the game on your phone, you need to manually add your gmail as a tester. I have a personal gmail I’m using on my phone and a DIFFERENT gmail to log on my developer account, so for that simple reason couldn’t get the authentication to finish on my phone. Your developer account is added as a tester automatically but any additional testers have to be added manually. This could be the reason why for some people it never works during testing but does work after publishing.

http://answers.unity.com/answers/1532378/view.html

Hello, i’am also having a similar problem.
If i do a build and run in unity, the leader board works perfectly. But after i publish the game in internal test it doesn’t display anything anymore. I download it from google play store, and it doesn’t display anything. Does anyone know why?
Thank you

If you didnt try it yet, you have to enter your email in your app release but also in your game services

Hi, after weeks of rage and despair I’ve given up on implementing the google play leaderboards. As suddenly one of my user found out how to make the leaderboard work…

First of all: the first pitfall for me was to recognize that now there is a new way how apps are being signed. Google only allows to upload .aab-bundles since August 2019. Unity’s key signing is applied to the bundle BUT since aab is distributed as different apks for different architectures by the store itself, there is an additional key signing!
So you have to ensure that the oauth in the developer console uses the hash of the singing made BY THE STORE. Not by Unity… Thanks to google you can read this in the documentation… NOT…

So far so good. The user were able to use Google Play but still no leaderboard for them. They could saw my personal (developer) score but couldn’t submit their own. The error always was some cryptic “ERROR Code 3” stuff which - according to the documentation - was due to singing problems.
So I switched plugin versions and also switched from Ultimate Mobile Asset Pack back to the official Google Play Unity SKD… but still no difference…
After weeks of despair I finally gave up. No Google Play Services ever again!!

Some weeks later an user made an observation… to submit your score, you as an user, have to explicitly allow google to show your activity publicly. To enable this, you have to go to google play (not the play store) and enable in the settings, that everyone can see your activity… oh boy…

I have to say, that nothing else was EVER a bigger pain to implement that google play services.

2 Likes

Wow, thank you!

A week later and my score finally shows up… Here I thought my code was wrong, nope you have to enable public visibility to your Google Play profile facepalm. Sure wish it would state somewhere in the documentation.

I’ve implemented Steam API and Nintendo Switch before, but yes GPS has been a real pain. Almost everything is working now after many many tutorials and countless forum searches.

1 Like

I’m totally with you… after a bit of testing I was coming to the conclusion that by uploading an AAB or even APK the Google Play is signing with its own key to the Internal test tracks. If I just sign with my key and install directly to my phone, the leaderboards show. Can you tell me how did you got the Google Plays Store signing key information? Thank you in advance.

Good to know!

I’m confused about this… Nowhere in the google play developer console can I find anything about this “oauth”. They only ‘signing’ part done was the keystore signing under “publishing settings” in unity, which either fails or succeeds. If succesful, google play accepts the app as valid, but that doesn’t have anything to do with leaderboards, does it?

I am struggling too. When I checked the Development Build, I could see the leaderboard and post scores. But when I uncheck the Development build. I could not even sign in. So, I don’t know if it would work in live version. Although I don’t have any users yet.