Google Play Games Not Working

Hi all. Over the past few days, my coding partner and I have been painstakingly trying to implement Google Play Games into our upcoming Android title. We have recently come across a fairly large hurdle that we cannot seem to find a solution for despite many other forum posts and StackOverflow answers we have tried to use. The issue is that after all of the setup, Google Play Games does not appear in our game in any capacity (at the start or any action affiliated with GPG). The addition of trying to get this into the game has also caused multiple errors when trying to build the game.

Unity version: 2019.4.14f1
Google Play Games Version: 10.12
Target platform: Android

Fixes attempted to get Google Play Games to work/appear in-game to not result

  • Downgrading Google Play Games from its latest version of 10.12 to 0.9.64 to no change
  • Uninstalling and reinstalling Google Play Games at least 4 times
  • Using a new scene only using a script from a tutorial linking to Google Play Games
  • Redoing the Play Games services configuration in the Google Play Console ~3 times
  • Using a Custom Proguard File - with ~5 different lists of files suggested by other posts
  • Not using a Custom Proguard File
  • Project Settings\Player\Minify both Release and Debug set to Proguard
  • Using Jetifier set to true
  • Doing both ā€˜Resolve’ and ā€˜Force Resolve’
  • Published on the Play Games services configuration
  • Uploading the game to the Google Play Console, and playing a downloaded version from an internal testing release
  • Removing Admob, and retrying the steps above
  • *Strip Engine Code has been both tried enabled and disabled
  • *Both Development Build and non-Development Build

Issues faced when compiling or after built:

  • Meta-INF/androidx.legacy_legacy-support-core-utils.version

  • Fixed with Assets\External Dependency Manager\Android Resolver\Delete Resolved Libraries

  • Builds once after with no errors

  • This error still occurs after removing Admob

  • Duplicate android class files

  • Fixed with Assets\External Dependency Manager\Android Resolver\Delete Resolved Libraries

  • Builds once after with no errors

  • Exception class not found com.google.android.gms.games.Games when running on Android

  • Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.Games

  • Appears after the game starts on Android

  • This error still occurs after removing Admob

  • Versions 10.06, 9.64 and 9.58 of Google Play Games produce a 'JAVA_HOME environment references error

  • Resolved by changing the JDK and SDK to not Unity Default

My analysis:

One of the last-ditch errors was believing it was Admob causing the issue. I gutted it from the project entirely and followed the same steps of adding it to the Google Play Console for download. Upon trying the game, GPG was not there. I tried building it from Unity and the last error I got before writing this post was the ClassNotFound, which did not make sense to me as I had Proguard on to prevent that. The game does not give this error when run in the editor (though does not function, as expected).

I have composed a list of the items we have searched through to both install GPG and to find an answer to get it to work:

Any advice on getting this to work would be appreciated, and I can share any images or code necessary should it help to fix the issue.

To add to my efforts of getting this resolved -

I created a new, empty project. I added some basic UI and imported the Google Play Games package, added the XML resource and it worked. Eventually moved all gameplay elements to this project and the game worked. Tried to add Google Admob and it resulted in the same effects as before - Deletes the class file and does not function, leaving me at Step 1.

Unity version is the same - 2019.4.14f1
Google Play Games version is 10.12
Admob version is 6.1.0

Edit -

Also recently read this closed issue on the Google Play Games Github - plugin no longer compatible with other google plugins (admob/analytics) Ā· Issue #2648 Ā· playgameservices/play-games-plugin-for-unity Ā· GitHub - stating at the time in July 2019 that the plugins were not compatible with each other. Could this still be the issue?

any luck with this? I can’t even get the sample project to work that is provided in the github repo. i believe i have followed all of the steps correctly but still no luck

Still somebody with these problems?
I solved it by switching to Unity 2020.3.22f1. Tried everything else before that.

Maybe that helps someone. Of course, the steps described above by Chapalato must be performed first.

I also use AdMob and I have 2 keys, so it works via direct build from Untiy and via GooglePlayConsole Internal Test .

1 Like

Check if any proguard files are active. This usually happens if you have any obfuscation/proguard enabled in your project.

If any one looking for a leaderboards/achievements solution (for iOS & Android) which is constantly supported, you can give a try with our Cross Platform Native Plugins : Essential Kit plugin. We constantly monitor the product and update the fixes so that you don’t need to waste your valuable time. We have 14+ more features in the same plugin.

It is unbelievably difficult to get Google Play Games services to work in Unity. I have been dealing with it since 2018. I remember spending DAYS to get it working. The documentation is useless, and I browses just about all forum posts just like you, finding hundreds of frustrated people, each spending hours fumbling around blindfolded to get it to work…

Let me give you an example on how the documentation is useless, this is from the package github instructions page:

Notice ā€œDepending on if you are using the SDK manager from Android Studio, or using the standalone SDK manager, the name of the components may be differentā€

That’s great, only ā€œGoogle Play Servicesā€ and ā€œAndroid 6.0ā€ is visible in the SDK manager, and I spend hours of googling how to find these other mysterious requirements - without luck.

Anyway, one day I got it to work and was SO relieved. But about a year later it stopped working for unknow reason, I spend a week trying to get it to work again, but no cigar. And I actually stopped working on the project in 2020 because of this… Only a month ago I decided to pick up the project again, and get rid of google play games all together, and implement Unity Gaming Services instead. But now I realize that I am kind of gonna need it anyway, because I need to sign people in to a identity provider… So I gave gpgs a shot again for the 4th time. And my head is literally exploding. Never had I had an as horrible implementation experience, there are literally hundreds of post all with different errors, and people seem to randomly fix (or not) their issue by spending hours trying out just about everything, and there seems to be no pattern in what works for who, there’s just so many thing that can be a problem…

I’ve read someone saying, ā€œoh but the andoid SDK that comes with unity is not compatible with the gpgs packageā€ you need to download another SDK and point your unity editor to use that sdk - this worked for some people, but not for others, and wasn’t necessary for all.

2 Likes

I have been fortunate enough to get most things to work properly with GPGS and have been playing around with it for about a year now in my current project. If there is something you currently having an issue with, I may be able ot point you in the right direction. I do agree that working with google’s plugins is worse than a nightmare, but it is unfortunately ā€œnecessaryā€ā€¦

That’s very kind of you! At the moment I have implemented Authentication with Facebook as identity provider, using the facebook SDK instead - this went a lot smoother, as the resolver could resolve everything, and I didn’t have to get some specific version of JDK and didn’t have to make modifications to the android NDK or SDK. I did have to fiddle a bit around with proguard though - but it was less painful…

I do though believe that I will need GPGS in the future… I will come back here and cry for help then :wink:

1 Like

I know it’m few years behind, but in cases of Java’s ClassNotFound exception, doesn’t adding the missing class’ path to the custom proguard solve the issue?

I’ve had a similar error with v11.01, claiming that com.google.android.gms.games.PlayGames was not found, so I added:
-keep class com.google.android.gms.games.PlayGames.* { *; }
to my custom proguard, and it seems to be working now (at least for me).

Thanks for the info!

Working on a deeper level with java, xml, the proguard file, and many android specific features is new in general to me and I’m sure it is for a lot of others as well. I’m still exploring and learning all of these features and languages. I’m sure many basic users such as myself assume (or rather, expect) that a plugin should work without having to apply custom fixes for something that should just work.

Дompletely agree!

I spent more than a week before I realized that the problem was in the proguard-user.txt file :eyes:

Unity version: 2019.4
Google Mobile Ads v7.1.0
Google Play Games v10.12
Target platform: Android

If you are using the ā€œCustom Proguard Fileā€ option you must add the following lines to your proguard-user.txt file

-keep class com.google.android.gms.games.PlayGames { ; }
-keep class com.google.android.gms.games.leaderboard.
* { ; }
-keep class com.google.android.gms.games.snapshot.
* { ; }
-keep class com.google.android.gms.games.achievement.
* { ; }
-keep class com.google.android.gms.games.event.
* { ; }
-keep class com.google.android.gms.games.stats.
* { ; }
-keep class com.google.android.gms.games.video.
* { ; }
-keep class com.google.android.gms.games.
{ ; }
-keep class com.google.android.gms.common.api.ResultCallback { ; }
-keep class com.google.android.gms.signin.
{ ; }
-keep class com.google.android.gms.dynamic.
* { ; }
-keep class com.google.android.gms.dynamite.
* { ; }
-keep class com.google.android.gms.tasks.
* { ; }
-keep class com.google.android.gms.security.
* { ; }
-keep class com.google.android.gms.base.
* { ; }
-keep class com.google.android.gms.actions.
* { ; }
-keep class com.google.games.bridge.
* { ; }
-keep class com.google.android.gms.common.ConnectionResult { ; }
-keep class com.google.android.gms.common.GooglePlayServicesUtil { ; }
-keep class com.google.android.gms.common.api.
{ ; }
-keep class com.google.android.gms.common.data.DataBufferUtils { ; }
-keep class com.google.android.gms.games.quest.
{ ; }
-keep class com.google.android.gms.nearby.
{ *; }

Links

https://stackoverflow.com/questions/61013678/google-play-games-service-in-unity-doesnt-authenticate