Google play services doesnt displays leaderboard after Auth

1.4k views Asked by At

Its a very weird have invested a lot of time in this. So asking here.

I am using this plugin and followed the steps https://github.com/playgameservices/play-games-plugin-for-unity

I just want to use Google play services in release mode for leaderboard only (i am using in alpha launch)

Here is my code for Auth in GPlay services :

void Awake(){
    PlayerPrefs.SetInt("GameOverCount",0);

    #if UNITY_ANDROID
    Authenticate ();
    #endif}

I have configured Gplay setup by providing 10+ digit Client ID

I have generated OAuth Client ID from Google APis using SHA1 of release.keystore that i am using. In Gplay service in DEveloper console : I have published the linked apps without any errors

public void Authenticate() {
    if (Authenticated || mAuthenticating) {
        Debug.LogWarning("Ignoring repeated call to Authenticate().");
        return;
    }


    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
        .EnableSavedGames()
            .Build();
    PlayGamesPlatform.InitializeInstance(config);

    // Activate the Play Games platform. This will make it the default
    // implementation of Social.Active
    PlayGamesPlatform.Activate();

    // Set the default leaderboard for the leaderboards UI
    ((PlayGamesPlatform) Social.Active).SetDefaultLeaderboardForUI(leaderboardID_android);



    // Sign in to Google Play Games
    mAuthenticating = true;
    Social.localUser.Authenticate((bool success) => {
        mAuthenticating = false;
        if (success) {

            UnityAnalytics.CustomEvent("Auth Completed", new Dictionary<string, object>
                                       {
                { "isAuthDone", true }
            });

            if(showScores){

                Social.Active.ShowLeaderboardUI();
                Debug.Log("should show leaderborad");
            }
            // if we signed in successfully, load data from cloud
            Debug.Log("Login successful!");
        } else {
            // no need to show error message (error messages are shown automatically
            // by plugin)
            Debug.LogWarning("Failed to sign in with Google Play Games.");

            UnityAnalytics.CustomEvent("Auth Failed", new Dictionary<string, object>
                                       {
                { "isAuthDone", false }
            });

        }
    });
}
#if UNITY_ANDROID
    if (Authenticated) {
        showScores = false;
        ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(leaderboardID_android);
        Social.ShowLeaderboardUI();
        Debug.Log("should show leaderborad");

        UnityAnalytics.CustomEvent("Authenticated and show android leaderboard", new Dictionary<string, object>
                                   {
            { "isShowing", true }
        });

    }else{
        showScores = true;
        Authenticate();
    }
    #endif

Next, i release the alpha and check on android devices - i get a screen saying connecting to google play games...connects processes and then goes off the screen. It seems like it authenticates and goes off. But doesn't displays leaderboard for some reason. I am not able to understand why its happening and what's missing.

In my unity analytics, only once scores aren't loaded and i played it 20-30 times : enter image description here

In my Developer console, Number of scores is empty :

enter image description here

Can anybody pls help in this, i can provide more details to people who can help / want to help....Thanks...

1

There are 1 answers

0
Navid Jahangiri On

Choose Proguard for Minify > Release and Copy the content into Assets/Plugins/Android/proguard-user.txt

-keep class com.google.unity.** {
   *;
}
-keep public class com.google.android.gms.ads.**{
   public *;
}
-keep public class com.google.ads.**{
   public *;
}
-keepattributes *Annotation*
-dontobfuscate
-keep class com.google.android.gms.games.PlayGames { *; }
-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.** { *; }

It's work for me.