play-games-plugin-for-unity
play-games-plugin-for-unity copied to clipboard
Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames
Describe the bug I've installed latest version of the plugin 0.11.01 and I´m getting this error when executing, once build, the login: Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames
I'm getting the error by connecting my phone and using Android Logcat. Actually the full error is:
AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:454) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.access$500(Unknown Source:0) at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:126) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) Caused by: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames ... 9 more at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0 2
The code I'm using for now is this:
`using UnityEngine; using GooglePlayGames; using GooglePlayGames.BasicApi;
public class GooglePlayServicesManager : MonoBehaviour { public static GooglePlayServicesManager Instance { get; private set; } public bool isConnectedToGPS = false; private SignInStatus status;
private string leaderBoardId = "xxxxxx";
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
// Initialize Google Play Services here if needed
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
}
else
{
Destroy(gameObject);
}
}
public void Start()
{
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
}
public void LogIn()
{
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
}
internal void ProcessAuthentication(SignInStatus status)
{
if (status == SignInStatus.Success)
{
// Continue with Play Games Services
}
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).
}
}
public void ShowLeaderboard()
{
PlayGamesPlatform.Instance.ShowLeaderboardUI(leaderBoardId);
}
public void ShowAchievements()
{
PlayGamesPlatform.Instance.ShowAchievementsUI();
}
public void UnlockAchievement(string achievementID)
{
PlayGamesPlatform.Instance.ReportProgress(achievementID, 100.0f, (bool success) =>
{
if (success)
{
Debug.Log("Score reported successfully!");
}
else
{
Debug.LogError("Failed to report score.");
}
});
}
public void ReportScore(long score, string leaderboardID)
{
PlayGamesPlatform.Instance.ReportScore(score, leaderboardID, (bool success) =>
{
if (success)
{
Debug.Log("Score reported successfully!");
}
else
{
Debug.LogError("Failed to report score.");
}
});
}
} `
I´ve tried everything I've seen about this error and similar ones. Custom Proguard file, fixing the file android dependencies, changing things inside the manifest, using resolve and force resolve, checking debug and release in minification... but none of those are working for me. Also changed the Sha1 from my play console inside developers hub. I'm still getting the error and I don't know what else do or try.
Please help.
Versions
- Unity version: 2021.3.25f1
- Google Play Games Plugin for Unity version: 0.11.01
Additional context It's a 2d game with 2d Core installed, Unity ads, another plugin for translations and nothing else. Shouldnt be a conflict with those.
This is still happening. Any ideas?
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
I'm using unity 2022.3.4f1 and GooglePlayGamesPlugin-0.11.01 Tried all of the above and nothing worked for me.
I fixed the issue by add this line of code in Plugins/Android/mainTemplate.gradle
dependencies {
implementation "com.google.android.gms:play-services-games-v2:+"
}
unity 2021.3.33, plugin 0.11.01
This is still happening.
Does anyone know what an Android project looks like when properly exported?
this file: Assets/GooglePlayGames/com.google.play.games/Editor/m2repository/com/google/games/gpgs-plugin-support/0.11.01/gpgs-plugin-support-0.11.01.srcaar
if rename and unzip this file, open directory, rename and unzip classes.jar, you will find some class in folder classes - unzip\com\google\games\bridge
I don't know what is .srcaar file. But my gut tells me that this file should be exported to an Android project, or unzipped to an Android project.
I'm using unity 2022.3.4f1 and GooglePlayGamesPlugin-0.11.01 Tried all of the above and nothing worked for me.
I fixed the issue by add this line of code in Plugins/Android/mainTemplate.gradle
dependencies { implementation "com.google.android.gms:play-services-games-v2:+" }
This worked for me! Thank you SIR!
Ref: https://github.com/googlesamples/unity-jar-resolver/issues/208