- Home /
Android game crashes on startup because of Google Play
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).
can you post the crash log from the device? it would make it easier to find out what's wrong.
How do I get the crash log? I only found a bunch of ways that either required me to have linux or to have my android device connected to my computer (which neither case happends).
EDIT: Sorry, when it comes to cases like this I'm a real rookie :/
you should connect an android device to your computer, reproduce the crash and then get the device log using logcat.
Answer by skillbow · Mar 14, 2017 at 06:02 PM
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.
I done that, but now the game doesn't even build. Im getting the following error: CommandInvokationFailure: Failed to re-package resources. See the Console for details. Android$$anonymous$$anifest.xml:19: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version')
Any ideas on what to do?
Can you post a screenshot of your Assets/Plugins/Android folder. Also what version of Unity are you running?
You're missing play-services-base-10.0.1.aar and play-services-basement-10.0.1.aar
I'm sorry to bother you again. But out of a sudden, my game doesn't build and just gives me this error: https://pastebin.com/k5zw07$$anonymous$$T I swear, I have nightmares with Android$$anonymous$$anifest.....
I'll take a proper look through the errors in a moment but have noticed that "play-services-basement-9.0.0" is in your list. It may make no difference at all but it's probably worth taking out just to make sure.
Wow it worked. I don't know why as the only times I changed those files was to solve the previous error and at that time it was able to build. Only now all of a sudden it started acting up. But all is well, thank you very much. Have a nice day :)
Answer by liortal · Mar 14, 2017 at 05:51 PM
Your crash might be related to this bug: https://github.com/playgameservices/play-games-plugin-for-unity/issues/1635
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).
I done that, but now the game doesn't even build. Im getting the following error: CommandInvokationFailure: Failed to re-package resources. See the Console for details. Android$$anonymous$$anifest.xml:19: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version')
Any ideas on what to do?
you probably didn't include the google play services libraries in your project. you should make sure that they exist (they should be automatically resolved using the "resolver" infrastructure that most plugins include).
If you still can't make it, plz contact me via this link- https://www.fiverr.com/lysergide/fix-android-build-issues-in-your-unity3d-project
If you use the resolver I think it will keep promoting you to use the 10.2.0 versions