playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.43k stars 953 forks source link

PlayGamesPlatform isn't working on Internal Test Track #3216

Open MiniatureGiants opened 1 year ago

MiniatureGiants commented 1 year ago

I have imported the package and setup a gameobject on my main screen which contains a script with the following code:

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

public class GooglePlayServices : MonoBehaviour {

[SerializeField] TextMeshProUGUI loginStatus;
// Start is called before the first frame update
void Awake() 
{
PlayGamesPlatform.Activate();
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
}

internal void ProcessAuthentication(SignInStatus status) 
{
  if (status == SignInStatus.Success) 
  {
    // Continue with Play Games Services
    loginStatus.text = "Login Status: Success";
    Debug.Log("Authentication Success");
  } 
  else 
  {
    // Disable your integration with Play Games Services or show a login button
    // to ask users to sign-in. Clicking it should call
    // PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication).
    loginStatus.text = "Login Status: Failed";
    Debug.Log("Authentication Failed");
  }
}

The text field I've setup isnt even updating to reflect a status leading me to believe that this code is not executing for some reason.

I am using Unity 2021.3.12f1 and installed the JDK and Android SDK via the Unity Hub installed with this version of Unity. I've obviously created the project on the Developer Console and gone through the process to setup OAuth and credentials using the info as supplied by the console. What am I missing here?? Why is this not working?

MiniatureGiants commented 1 year ago

I've now opened the Android SDK Manager and made sure Google Play Services is installed (it wasn't) and I can't see the Android Support Library in the list of options to install. I have now also created 2 buttons to attempt a Manual sign-in using both the Google & Unity provided paths. I am getting the below errors in the logcat. Please - someone point me in the right direction as this is utterly, ludicrously, frustrating:

2023/02/04 12:37:57.334 20655 20677 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 12:37:57.334 20655 20677 Error Unity java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 12:37:57.334 20655 20677 Error Unity at java.lang.Class.classForName(Native Method) 2023/02/04 12:37:57.334 20655 20677 Error Unity at java.lang.Class.forName(Class.java:454) 2023/02/04 12:37:57.334 20655 20677 Error Unity at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 2023/02/04 12:37:57.334 20655 20677 Error Unity at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) 2023/02/04 12:37:57.334 20655 20677 Error Unity at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) 2023/02/04 12:37:57.334 20655 20677 Error Unity at android.os.Handler.dispatchMessage(Handler.java:102) 2023/02/04 12:37:57.334 20655 20677 Error Unity at android.os.Looper.loopOnce(Looper.java:226) 2023/02/04 12:37:57.334 20655 20677 Error Unity at android.os.Looper.loop(Looper.java:313) 2023/02/04 12:37:57.334 20655 20677 Error Unity at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 2023/02/04 12:37:57.334 20655 20677 Error Unity Caused by: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 12:37:57.334 20655 20677 Error Unity ... 9 more 2023/02/04 12:37:57.334 20655 20677 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 2023/02/04 12:37:57.334 20655 20677 Error Unity at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0 2023/02/04 12:37:57.334 20655 20677 Error Unity at UnityEngine.AndroidJavaClass._AndroidJa 2023/02/04 12:38:06.422 20655 20936 Warn Choreographer Frame time is 0.020694 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase. 2023/02/04 12:38:07.210 20655 20936 Warn Choreographer Frame time is 0.020751 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase. 2023/02/04 12:38:10.209 20655 20655 Info ViewRootImpl@5ca8ae[UnityPlayerActivity] ViewPostIme pointer 0 2023/02/04 12:38:10.321 20655 20655 Info ViewRootImpl@5ca8ae[UnityPlayerActivity] ViewPostIme pointer 1 2023/02/04 12:38:10.340 20655 20677 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 12:38:10.340 20655 20677 Error Unity java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 12:38:10.340 20655 20677 Error Unity at java.lang.Class.classForName(Native Method) 2023/02/04 12:38:10.340 20655 20677 Error Unity at java.lang.Class.forName(Class.java:454) 2023/02/04 12:38:10.340 20655 20677 Error Unity at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 2023/02/04 12:38:10.340 20655 20677 Error Unity at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) 2023/02/04 12:38:10.340 20655 20677 Error Unity at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) 2023/02/04 12:38:10.340 20655 20677 Error Unity at android.os.Handler.dispatchMessage(Handler.java:102) 2023/02/04 12:38:10.340 20655 20677 Error Unity at android.os.Looper.loopOnce(Looper.java:226) 2023/02/04 12:38:10.340 20655 20677 Error Unity at android.os.Looper.loop(Looper.java:313) 2023/02/04 12:38:10.340 20655 20677 Error Unity at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 2023/02/04 12:38:10.340 20655 20677 Error Unity Caused by: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 12:38:10.340 20655 20677 Error Unity ... 9 more 2023/02/04 12:38:10.340 20655 20677 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 2023/02/04 12:38:10.340 20655 20677 Error Unity at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0 2023/02/04 12:38:10.340 20655 20677 Error Unity at UnityEngine.AndroidJavaClass._AndroidJa

MiniatureGiants commented 1 year ago

So after doing a few things there is slight progress. I am not sure what has made the difference but I have:

  1. Added extra accounts to the Testers associated with the Internal Test Track releases (somehow it didnt have the Internal Test group listed under testers)
  2. Checked the 'Custom ProGuard' that some people have noted
  3. Opened the Android SDK Manager as mentioned and downloaded the latest Google Play Services package
  4. Reverted my Unity Build to 'Release' (Changing it made no difference).

Now, when I build to my phone I still get nothing. However when I create a release on the Developer Console for internal testing, the GPS 'Welcome'/Player login is popping immediately after opening the app (i.e. during the Unity Splashscreen). I'm not sure if this is because its automatically trying that, or if its running the above code.

HOWEVER, there are 2 issues now.

When I attempt to have a button run a method to Social.ShowAchievementUI() I see the following:

I still have the above errors showing up in Logcat when opening the app:

2023/02/04 14:22:20.204 26336 26369 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 14:22:20.204 26336 26369 Error Unity java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 14:22:20.204 26336 26369 Error Unity at java.lang.Class.classForName(Native Method) 2023/02/04 14:22:20.204 26336 26369 Error Unity at java.lang.Class.forName(Class.java:454) 2023/02/04 14:22:20.204 26336 26369 Error Unity at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 2023/02/04 14:22:20.204 26336 26369 Error Unity at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) 2023/02/04 14:22:20.204 26336 26369 Error Unity at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) 2023/02/04 14:22:20.204 26336 26369 Error Unity at android.os.Handler.dispatchMessage(Handler.java:102) 2023/02/04 14:22:20.204 26336 26369 Error Unity at android.os.Looper.loopOnce(Looper.java:226) 2023/02/04 14:22:20.204 26336 26369 Error Unity at android.os.Looper.loop(Looper.java:313) 2023/02/04 14:22:20.204 26336 26369 Error Unity at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 2023/02/04 14:22:20.204 26336 26369 Error Unity Caused by: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 14:22:20.204 26336 26369 Error Unity ... 9 more 2023/02/04 14:22:20.204 26336 26369 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 2023/02/04 14:22:20.204 26336 26369 Error Unity at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0 2023/02/04 14:22:20.204 26336 26369 Error Unity at UnityEngine.AndroidJavaClass._AndroidJa

  1. The logcat says re: Achievements: 2023/02/04 14:23:28.754 26336 26369 Info Unity ShowAchievementsUI not implemented

I have created 5 achievements on the Google Play Dev Console which are currently in Draft (Available to Testers).

Again, as above, I'm not sure where to go from here and would appreciate any pointers in the right direction.

Stencil commented 1 year ago

I think I have the issue, I don't know if internal testing allows sign in to Google Play Services. But I'm pretty sure it does, because I've seen tutorials on YouTube, but with an older Play Services version.

Anyways I am using this code to test

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

public class GPGS : MonoBehaviour
{
    public Text statusTxt;
    // Start is called before the first frame update
    void Start()
    {
        PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication); //automatically creates the build configuration, activates it and authenticates the user.
    }
    internal void ProcessAuthentication(SignInStatus status) // called on start, this handles the call back method received from play games platform and processes the result.
    {
        if (status == SignInStatus.Success)
        {
            statusTxt.text = "Successful Sign In";
        }
        else if (status == SignInStatus.InternalError)
        {
            statusTxt.text = "Failed due to internal error";
        }
        else if (status == SignInStatus.Canceled)
        {
            statusTxt.text = "Failed due to Canceled status";
        }
        else
        {
            statusTxt.text = "This should never be triggered, not one of the call back responses.";
        }
    }
    public void TriggerManualSignIn() // the script attached to the button to trigger a manual signin.
    {
        PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication);
    }
}

and it says cancelled even when I press a button to manual sign in.

as said before

  1. I am Using Internal Testing in Play Console
  2. My publishing Status is "Testing" in the Console Cloud
  3. I have the same email testers in the Console Cloud and in the Play Console.
  4. The SHA 1 key I am using in the OAuth is the one generated in my Computer. (I heard that in Production you might use the one generated by Google Play Console, I haven't tested that yet, but I have to go to Production instead)

I hope this info helps you find something else, I will be still looking for a solution. See you around.

Stencil commented 1 year ago

Ok I fixed it. When you do Production tests (internal, closed,etc) in the OAuth credential use the SHA 1 provided by Play Console instead. Go to Google Play Console/Setup/App integrity/App signing/ copy the App Signing Key Certificate SHA-1 certificate fingerprint and paste it in the Cloud Console OAuth Credential you made.

MuradAlvv commented 1 year ago

So after doing a few things there is slight progress. I am not sure what has made the difference but I have:

  1. Added extra accounts to the Testers associated with the Internal Test Track releases (somehow it didnt have the Internal Test group listed under testers)
  2. Checked the 'Custom ProGuard' that some people have noted
  3. Opened the Android SDK Manager as mentioned and downloaded the latest Google Play Services package
  4. Reverted my Unity Build to 'Release' (Changing it made no difference).

Now, when I build to my phone I still get nothing. However when I create a release on the Developer Console for internal testing, the GPS 'Welcome'/Player login is popping immediately after opening the app (i.e. during the Unity Splashscreen). I'm not sure if this is because its automatically trying that, or if its running the above code.

HOWEVER, there are 2 issues now.

When I attempt to have a button run a method to Social.ShowAchievementUI() I see the following:

I still have the above errors showing up in Logcat when opening the app:

2023/02/04 14:22:20.204 26336 26369 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 14:22:20.204 26336 26369 Error Unity java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 14:22:20.204 26336 26369 Error Unity at java.lang.Class.classForName(Native Method) 2023/02/04 14:22:20.204 26336 26369 Error Unity at java.lang.Class.forName(Class.java:454) 2023/02/04 14:22:20.204 26336 26369 Error Unity at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 2023/02/04 14:22:20.204 26336 26369 Error Unity at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) 2023/02/04 14:22:20.204 26336 26369 Error Unity at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) 2023/02/04 14:22:20.204 26336 26369 Error Unity at android.os.Handler.dispatchMessage(Handler.java:102) 2023/02/04 14:22:20.204 26336 26369 Error Unity at android.os.Looper.loopOnce(Looper.java:226) 2023/02/04 14:22:20.204 26336 26369 Error Unity at android.os.Looper.loop(Looper.java:313) 2023/02/04 14:22:20.204 26336 26369 Error Unity at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 2023/02/04 14:22:20.204 26336 26369 Error Unity Caused by: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames 2023/02/04 14:22:20.204 26336 26369 Error Unity ... 9 more 2023/02/04 14:22:20.204 26336 26369 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 2023/02/04 14:22:20.204 26336 26369 Error Unity at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0 2023/02/04 14:22:20.204 26336 26369 Error Unity at UnityEngine.AndroidJavaClass._AndroidJa

  1. The logcat says re: Achievements: 2023/02/04 14:23:28.754 26336 26369 Info Unity ShowAchievementsUI not implemented

I have created 5 achievements on the Google Play Dev Console which are currently in Draft (Available to Testers).

Again, as above, I'm not sure where to go from here and would appreciate any pointers in the right direction.

Could you solve it?

RaidelRoss commented 1 year ago

Ok I fixed it. When you do Production tests (internal, closed,etc) in the OAuth credential use the SHA 1 provided by Play Console instead. Go to Google Play Console/Setup/App integrity/App signing/ copy the App Signing Key Certificate SHA-1 certificate fingerprint and paste it in the Cloud Console OAuth Credential you made.

Excellent this solution, you have saved my job :)

image (4) image

What I understand is that Google changes the key of the final published application, which has to match the developer account key for the login with Google Play Games services to work properly.

restush commented 12 months ago

I done everything, still not working. But then I try to update to latest External Dependency from Google then it works now.

rami-al-rahim commented 6 months ago

Hi I tried to change this line of code in GooglePlayGamesPluginDependencies.xml form this <repository>Packages/com.google.play.games/Editor/m2repository</repository> to this <repository>Assets/GooglePlayGames/com.google.play.games/Editor/m2repository</repository> I hope this help you