on how to implement a leaderboard. I got a huge problem that i can’t fix, it doesn’t have any sense. The code is this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class PlayGamesController : MonoBehaviour {
public Text mainText;
// Start is called before the first frame update
void Start() {
mainText.color = Color.green;
AuthenticateUser();
mainText.color = Color.cyan;
}
void AuthenticateUser() {
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
Social.localUser.Authenticate((bool success) => {
if (success) {
Debug.Log("Logged into Google Play Game Services");
SceneManager.LoadScene(2);
}
else {
Debug.LogError("Unable to sign into Google Play Game Services");
mainText.text = "Could not login to google play game services";
mainText.color = Color.red;
}
});
}
public static void PostToLeaderboard(long newScore) {
Social.ReportScore(newScore, GPGSIds.leaderboard_highscore, (bool success) => {
if (success) {
Debug.Log("Posted new score to leaderboard");
}
else {
Debug.LogError("Unable to post new score to leaderboard");
}
});
}
public static void ShowLeaderboardUI() {
PlayGamesPlatform.Instance.ShowLeaderboardUI(GPGSIds.leaderboard_highscore);
}
}
What’s the problem? I don’t get any compile error and when i run the code (i attached the script to an object on the main menu scene, the first one when the game starts) it seems working because it gives error saying that i could’nt login and the text color became red. When the game is builded and installed on my phone, nothing is working. I don’t even get the error “could not login” and the text doesn’t became red. I put the line “mainText.color = Color.cyan” after the call “AuthenticateUser()” and the color doesn’t change. The code get stucked inside that function and i don’t know why because in the editor is working. Any suggestion?
Failed to run ‘C:\Users\Andrea\Documents\Progetti\Unity\EnhancedFlappy\Temp\PlayServicesResolverGradle\gradlew.bat --no-daemon -b “C:\Users\Andrea\Documents\Progetti\Unity\EnhancedFlappy\Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle” “-PANDROID_HOME=C:/Program Files/Unity/Hub/Editor/2019.3.0f5/Editor/Data/PlaybackEngines/AndroidPlayer\SDK” “-PTARGET_DIR=C:\Users\Andrea\Documents\Progetti\Unity\EnhancedFlappy\Assets\Plugins\Android” “-PMAVEN_REPOS=file:///C:/Users/Andrea/Documents/Progetti/Unity/EnhancedFlappy/Assets/GooglePlayGames/Editor/m2repository” “-PPACKAGES_TO_COPY=com.google.games:gpgs-plugin-support:0.10.09” “-PUSE_JETIFIER=0” “-PDATA_BINDING_VERSION=3.4.0”’
stdout:
stderr:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/C:/Users/Andrea/.gradle/wrapper/dists/gradle-5.1.1-bin/90y9l8txxfw1s2o6ctiqeruwn/gradle-5.1.1/lib/groovy-all-1.0-2.5.4.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
What went wrong:
Could not compile settings file ‘C:\Users\Andrea\Documents\Progetti\Unity\EnhancedFlappy\Temp\PlayServicesResolverGradle\settings.gradle’.
startup failed:
General error during semantic analysis: Unsupported class file major version 57
java.lang.IllegalArgumentException: Unsupported class file major version 57
at groovyjarjarasm.asm.ClassReader.(ClassReader.java:184)
at groovyjarjarasm.asm.ClassReader.(ClassReader.java:166)
at groovyjarjarasm.asm.ClassReader.(ClassReader.java:152)
at groovyjarjarasm.asm.ClassReader.(ClassReader.java:273)
at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81)
at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:254)
at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:192)
at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:172)
at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:128)
at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClassNullable(AsmReferenceResolver.java:59)
at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClass(AsmReferenceResolver.java:46)
at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveNonArrayType(AsmReferenceResolver.java:81)
at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveType(AsmReferenceResolver.java:72)
at org.codehaus.groovy.ast.decompiled.MemberSignatureParser.createMethodNode(MemberSignatureParser.java:55)
at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.lazyInitMembers(DecompiledClassNode.java:195)
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.