- Home /
Showing Google Play Game Leaderboard UI not working at all
Trying to figure out what went wrong with this GPG plugin. I followed the instructions and understand the document in order to test run the login and show leaderboard UI via this one. I did make the play games achievements + leaderboard via Google Play developer account, do the setup, copy-paste source, and done. Testing the ads via adding Admob Unity package and GPG Unity package and it worked perfectly. I even update some plugins for Android (etc. .aar files, firebase-common, manifest) in order to maximize compatibility and efficiency so that I could build APK without any issues that interfering the build-up.
However, there is one issue: after I logged in and trying to tap the "show leaderboard UI" button along with the button event that asks if the user is authenticated and it will allow you to record your latest highscore by updating it before showing the leaderboard UI. Here's how the code works:
First, at the Start() callback...
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
Next, here's the login/logout process...
public void LogInAccount() {
// Show dialog.
y = 0;
dialogPanel.SetActive (true);
dialogBackground.SetActive (true);
// You can logout if you're logged in.
if(Social.localUser.authenticated) {
((PlayGamesPlatform)Social.Active).SignOut ();
y = 0;
message.text = "Your account have been logged out.";
logButtonLabel.text = "Log-in via Google";
button.SetActive (true);
confirmSound.Play();
return;
}
// Check for status.
if (CheckNetwork.checkOnlineStatus ()) {
Social.localUser.Authenticate ((bool success) => {
if (success) {
// LOG IN SUCCESS! (Check if the email is identified or not.)
if((((PlayGamesLocalUser)Social.localUser).Email != null) || (((PlayGamesLocalUser)Social.localUser).Email != "")) {
y = 0;
message.text = "Login complete. However, email is not verified or unknown.";
logButtonLabel.text = "Log-out";
button.SetActive (true);
errorSound.Play();
} else {
y = 0;
message.text = "Login complete!\nYour email:" + ((PlayGamesLocalUser)Social.localUser).Email;
logButtonLabel.text = "Log-out";
button.SetActive (true);
confirmSound.Play();
}
} else if (!success) {
// LOG IN FAILED.
if((((PlayGamesLocalUser)Social.localUser).Email != null) || (((PlayGamesLocalUser)Social.localUser).Email != "")) {
message.text = "Login failed. Please try again later.\nYour email: ? ? ?";
} else {
message.text = "Login failed. Please try again later.\nYour email: " + ((PlayGamesLocalUser)Social.localUser).Email;
}
y = 0;
button.SetActive (true);
logButtonLabel.text = "Log-in via Google";
errorSound.Play();
}
});
} else {
message.text = "Connection is lost. Please enable online.";
button.SetActive (true);
}
}
And then, the show leaderboard callback/button event.
public void OpenLeaderboard() {
// Show dialog.
y = 0;
dialogPanel.SetActive (true);
dialogBackground.SetActive (true);
// Check for status.
if (Social.localUser.authenticated && CheckNetwork.checkOnlineStatus ()) {
// Updating your highscore...
Social.ReportScore ((long)Score.GetScore (),
AchievementReference.leaderboard_best_intergalactic_chasers_top_score,
(bool success) => {
if(success) {
// LEADERBOARD APPEARED!
dialogPanel.SetActive (false);
dialogBackground.SetActive (false);
confirmSound.Play();
Social.ShowLeaderboardUI();
// ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(AchievementReference.leaderboard_best_intergalactic_chasers_top_score);
} else {
y = 0;
message.text = "Load failed. Please try again later.";
button.SetActive (true);
errorSound.Play();
}
});
} else if (!Social.localUser.authenticated) {
y = 0;
confirmSound.Play();
button.SetActive (true);
if (!CheckNetwork.checkOnlineStatus ()) {
message.text = "Connection not available at a moment.";
} else if (CheckNetwork.checkOnlineStatus ()) {
message.text = "You must login first in order to see the leaderboard.";
}
}
}
At my first attempt, I do login (it shows the welcome sign sometimes) and tap the leaderboard button but nothing happens after 2 minutes. Second attempt, I do login-logout-login method and the GPG prompted me to select the Email address and the welcome username sign appeared on top. However, still...when I tapped the show leaderboard UI button and nothing happens after 3 minutes. I used this reference to gain more ideas on effective showing the leaderboardc UI and checked for the code sample. Final attempt, and I assumed that leaderboard UI won't show up until I publish the Game Services I've created (it was set for testing mode before) and see if the leaderboard UI is working or not. Then after a day or two, used the same method from first second attempt and still got no luck.
The question is: how come the leaderboard UI still won't show-up during test mode and even after published the game services via Google play Services developer section? The same thing happen in displaying in Achievements UI. What was the cause that preventing the leaderboard UI from showing up even if I did it correctly on the setup? I doubt it's the internet connection issues or wifi signal. The issues probably is the long load on a very simple game services I've made. I only created only two leaderboards (highscore and no. of ships destroyed) and five achievements on reaching certain score and no. of ships destroyed. Please help.
Also, aside from showing leaderboard UI issues, there is also an error that leaves the string value (actually, I'm retrieving with the email address selected) null or empty even if successfully logged in via Google account follow-up by the welcome username sign at the top of the screen.
UPDATE (As of 2:46 PM via Philippines, 7/5/2016): After I checked the bugs and offer some solution from S. Tarik Cetin, I checked on logcat about login. At first, I thought it's successful login. Then, I noticed this:
W/Unity (32099): *** [Play Games Plugin DLL] 07/05/16 14:33:54 -07:00 ERROR: E
xception launching token request: java.lang.ClassNotFoundException: com.google.g
ames.bridge.TokenFragment
W/Unity (32099):
W/Unity (32099): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
W/Unity (32099):
W/Unity (32099): *** [Play Games Plugin DLL] 07/05/16 14:33:54 -07:00 ERROR: U
nityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.ga
mes.bridge.TokenFragment
W/Unity (32099): java.lang.ClassNotFoundException: com.google.games.bridge.Tok
enFragment
W/Unity (32099): at java.lang.Class.classForName(Native Method)
W/Unity (32099): at java.lang.Class.forName(Class.java:217)
W/Unity (32099): at java.lang.Class.forName(Class.java:172)
W/Unity (32099): at com.unity3d.player.UnityPlayer.nativeRender(Native Me
thod)
W/Unity (32099): at com.unity3d.player.UnityPlayer.a(Unknown Source)
W/Unity (32099): at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
W/Unity (32099): Caused by: java.lang.NoClassDefFoundError: com/google/games/b
ridge/TokenFragment
W/Unity (32099): ... 6 more
W/Unity (32099): Caused by: java.lang.ClassNotFoundException: com.google.games
.bridge.TokenFragment
W/Unity (32099): at dalvik.system.BaseDexClassLoader.findClass(BaseDexCla
ssLoader.java:61)
W/Unity (32099): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
W/Unity (32099): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
W/Unity (32099): ... 6 more
W/Unity (32099): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] i
n <filename unknown>:0
W/Unity (32099): at UnityEn
Also, I encountered the status form my logcat when I did sign-in and out once.
W/Unity (32099): at UnityEn
I/Unity (32099): [Play Games Plugin DLL] 07/05/16 14:38:07 -07:00 DEBUG: Star
ting Auth Transition. Op: SIGN_OUT status: ERROR_NOT_AUTHORIZED
I/Unity (32099):
I/Unity (32099): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (32099):
Finally, here's the issue found during attempt on opening leaderboard UI directly.
W/Unity (32099): *** [Play Games Plugin DLL] 07/05/16 14:40:31 -07:00 ERROR: U
nityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.ga
mes.bridge.NativeBridgeActivity
W/Unity (32099): java.lang.ClassNotFoundException: com.google.games.bridge.Nat
iveBridgeActivity
W/Unity (32099): at java.lang.Class.classForName(Native Method)
W/Unity (32099): at java.lang.Class.forName(Class.java:217)
W/Unity (32099): at java.lang.Class.forName(Class.java:172)
W/Unity (32099): at com.unity3d.player.UnityPlayer.nativeRender(Native Me
thod)
W/Unity (32099): at com.unity3d.player.UnityPlayer.a(Unknown Source)
W/Unity (32099): at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
W/Unity (32099): Caused by: java.lang.NoClassDefFoundError: com/google/games/b
ridge/NativeBridgeActivity
W/Unity (32099): ... 6 more
W/Unity (32099): Caused by: java.lang.ClassNotFoundException: com.google.games
.bridge.NativeBridgeActivity
W/Unity (32099): at dalvik.system.BaseDexClassLoader.findClass(BaseDexCla
ssLoader.java:61)
W/Unity (32099): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
W/Unity (32099): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
W/Unity (32099): ... 6 more
W/Unity (32099): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] i
n <filen
UPDATE (As of 5:29 PM via Philippines, 7/5/2016): I made a mistake about checking if the email is empty or not. I made a reading wrong. Though, email address value still has issue and it should return with identified ones in string value and leaving with a blank when it reads not empty.
// LOG IN SUCCESS! (Check if the email is identified or not.)
if((((PlayGamesLocalUser)Social.localUser).Email != null) || (((PlayGamesLocalUser)Social.localUser).Email != "")) {
y = 0;
message.text = "Login complete!\nYour email:" + ((PlayGamesLocalUser)Social.localUser).Email;
logButtonLabel.text = "Log-out";
button.SetActive (true);
confirmSound.Play();
} else {
y = 0;
message.text = "Login complete. However, email is not verified or unknown.";
logButtonLabel.text = "Log-out";
button.SetActive (true);
errorSound.Play();
}
Answer by David_29 · Aug 12, 2016 at 05:12 AM
Since nobody helped me and my deadline is busted in total failure, my conclusion will provided nothing but myself. Okay, I checked and observed this tutorial from App Guruz and make the sample one. I observed how this game flow and use my package name to modify it. Luckily, the leaderboard UI finally showed up. I'm assumed that there are some certain particular problem or issues on plugins from Android (some library folders like firebase and .aar files) when I tried to compare mine from the sample roject form App Guruz website. Possibly compatibility issues. If you're came to make leaderboard UI's and stuff and relying on this Unity Plugin via GIT website, stay away from this crap. It's not worth to use it. Full of bugs, especially the Android plugins. Rely first on making your own GPG from scratch and observe the plugins and jars since I'm focused on Android only.
Answer by Saddamjit_Singh · Oct 12, 2017 at 07:18 AM
Add this in your Android Manifest -
<activity android:name="com.google.games.bridge.NativeBridgeActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
Weeks after wasting so much time on this issue, I found this. Fixed the issue. Thank you so much.
How do you get to the Android $$anonymous$$anifest?
Answer by BBQBoys · Aug 14, 2018 at 07:26 PM
Upload your .apk to Google Play.
It started working like a magic after 4 days of code editing - apparently certificate-related issue. You may use beta channel, do not forget to use debug signing key, elsewise Google Play will show an error after you upload .apk.
I hope this helps.
My app also has working leaderboard, you can check it here https://play.google.com/store/apps/details?id=com.HOTBBQ.MarshatheMarshmallow.
Your answer
Follow this Question
Related Questions
Google Play Games Services not showing achievements list and leaderboards even in Play Games app 1 Answer
Leaderboards for Android on Unity 1 Answer
Unity Google Play Service Plugin Social.localUser.Authenticate(…) App Crash 1 Answer
Firebase Apple Authentication Unity For Android Platefrom?????? 0 Answers