0
\$\begingroup\$

I've done everything as specified- Linked my app to play services in the developer console. Added the SHA1 from Applications -> Release Management -> App signing -> Upload certificate. Downloaded the latest 'play services' unity package from GitHub. Added the required 'resource' to the play services setup in unity editor. Added the following script to the 'Canvas' object:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using GooglePlayGames;
 using GooglePlayGames.BasicApi;
 using UnityEngine.SocialPlatforms;

 public class PlayGamesServices : MonoBehaviour
 {
     // Start is called before the first frame update
     void Start()
     {
         PlayGamesClientConfiguration clientConig = new 
         PlayGamesClientConfiguration.Builder().Build();
         PlayGamesPlatform.InitializeInstance(clientConig);
         PlayGamesPlatform.Activate();
         Social.localUser.Authenticate((bool success) =>
         {
             if (success)
                 Debug.Log("Logged In");
             else
                 Debug.Log("Failed to Log In");
         });
     }

     public static void PostToLederboard(long newHighScore)
     {

   Social.ReportScore(newHighScore,GPGSIds.leaderboard_global_high_score, (bool success) =>
         {
             if (success)
                 Debug.Log("New High Score posted");
             else
                 Debug.Log("Unable to post New High Score");
         });
     }

     public void ShowLeaderboard()
     {
    PlayGamesPlatform.Instance.ShowLeaderboardUI(GPGSIds.leaderboard_global_high_ score);
     }
 } 

I've already published my game to alpha testing and then implemented play services. I'm wondering if that's the problem.

I've run the adb logcat and this error popped up:

[Play Games Plugin DLL] 07/21/19 12:06:19 +05:30 ERROR: UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.games.bridge.TokenFragment 07-21 12:06:19.325 23287 23314 W Unity :

at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 07-21 12:06:19.325 23287 23314 W Unity :

at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <00000000000000000000000000000000>:0 07-21 12:06:19.325 23287 23314 W Unity :

at UnityEngine.AndroidJavaObject._CallStatic[ReturnType] (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 07-21 12:06:19.325 23287 23314 W Unity :

at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <00000000000000000000000000000000>:0 07-21 12:06:19.325 23287 23314 W Unity :

at GooglePlayGames.Android.AndroidTokenClient.DoFetchToken (System.Boolean silent, System.Action`1[T] callback) [0x00000] in <00000000000000000000000000000000>:0 07-21 12:06:19.325 23287 23314 W Unity :

at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 07-21 12:06:19.325 23287 23314 W Unity :

at GooglePlayGames.OurUtils.PlayGamesHelpe

I've tried reproducing the error by re-doing the exact same steps in an empty project and ended up with the same error.

Update: When i change Player Settings -> Publishing -> Minify -> Release to None and Debug to None the error is gone and play services sign-in was successful. This worked for the empty project, however when i make the same change in my original game project the build fails with errors. How do I build my game without errors when Minify is set to None?

\$\endgroup\$
1
\$\begingroup\$

I managed to solve the problem. Had to remove Advertisements package from Window -> Package Manager and then set Minify -> Release and Debug to None, then build the game and installed it on device and the play games login showed up.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.