Google play services not working

Hi guys,
i followed this tutorial

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?

If you’re using a newer version of Unity, install Android logcat in the package manager.

Then open logcat in Unity

Plug in your device, run your app, choose to filter at the top of the logcat window.

Otherwise, install

Which will let you bring up a runtime console to check for errors.

I did, there are lot of messages. What should i check? Maybe is this ?
05/18 22:58:21.820 3297 3319 Error Unity: AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.Games
05/18 22:58:21.820 3297 3319 Error Unity: java.lang.ClassNotFoundException: com.google.android.gms.games.Games
05/18 22:58:21.820 3297 3319 Error Unity: at java.lang.Class.classForName(Native Method)
05/18 22:58:21.820 3297 3319 Error Unity: at java.lang.Class.forName(Class.java:453)
05/18 22:58:21.820 3297 3319 Error Unity: at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
05/18 22:58:21.820 3297 3319 Error Unity: at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
05/18 22:58:21.820 3297 3319 Error Unity: at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
05/18 22:58:21.820 3297 3319 Error Unity: at android.os.Handler.dispatchMessage(Handler.java:102)
05/18 22:58:21.820 3297 3319 Error Unity: at android.os.Looper.loop(Looper.java:216)
05/18 22:58:21.820 3297 3319 Error Unity: at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
05/18 22:58:21.820 3297 3319 Error Unity: Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.google.android.gms.games.Games” on path: DexPathList[[zip file “/data/app/com.Drekar.EnhancedFlappy–t_6HuN2-lLJhGPL02tGYg==/base.apk”],nativeLibraryDirectories=[/data/app/com.Drekar.EnhancedFlappy–t_6HuN2-lLJhGPL02tGYg==/lib/arm64, /data/app/com.Drekar.EnhancedFlappy–t_6HuN2-lLJhGPL02tGYg==/base.apk!/lib/arm64-v8a, /system/lib64]]
05/18 22:58:21.820 3297 3319 Error Unity: at dal

From the looks of it, it is either not including a class, or it’s getting stripped out.

Try this and then do a build

If that doesn’t work, you’ll need to look into pro-guard to make sure the class isn’t being striped out at build time.

It fails. I tried also to recreate a whole new project but always fail (same error when importing the google play services asset)
Log

Running Gradle…

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”
Executing command: 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”

ERROR: Gradle failed to fetch dependencies.

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

FAILURE: Build failed with an exception.

  • Where:
    Settings file ‘C:\Users\Andrea\Documents\Progetti\Unity\EnhancedFlappy\Temp\PlayServicesResolverGradle\settings.gradle’

  • 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.

Hey, it passed a long time from this post. Anyway i had fixed it by using an older version of the google play service plugin if anyone needs

2 Likes

Which one did you use?