As the title sugests, my android game keeps crashing because of Google Play. I know this since, in the first cene, I have a script with the following code:
using UnityEngine;
using System.Collections;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
public class GooglePlayLogin : MonoBehaviour {
// Use this for initialization
void Start () {
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
Social.localUser.Authenticate((bool success) => {
Debug.Log(success);
});
DontDestroyOnLoad(this.gameObject);
}
}
I tried building the game with this script activated and deactivated and when I deactivate it, it doesn’t crash. I’ve done some research and found a thread where someone says that this problem was caused by having plugins within the project trying to access older versions of GooglePlay but from what I’ve seen there’s nothing like that (though I might have searched for it the wrong way so if anyone has any sugestions that would be appreciated).
I had the same problem and solved by following advice from this thread: https://github.com/playgameservices/play-games-plugin-for-unity/issues/1604
It seems there is an incompatibility between the GooglePlayGames plugin and version 10.2.0 of the Google Play Services. So the best thing to do is roll back Google Play Services to 10.0.1
The full steps are from tolgau on the above thread (about 7 comments down).
In addition to the thread answer I would suggest using PlayGamesPlatform.Instance.IsAuthenticated() instead of Social.localUser.authenticated if you want to check whether the user is currently authenticated.
Your crash might be related to this bug: Plugin Crash at Starting. · Issue #1635 · playgameservices/play-games-plugin-for-unity · GitHub
The solution is to force the project to use Google play services libraries with version 10.0.1.
You can force the “Google Play Services Resolver” to use a particular version, by editing a class named PluginVersion. This class contains all the configurations that are used by the resolver (including which google play services libraries to download and include in the project).