Question

I am getting an error on an import statement that I am using in order to try and implement Play Games with my app.

-The import com.google.android.gms.games.GamesClient cannot be resolved

I have BaseGameUtils referecncing google-play-services_lib, and my project references BaseGameUtils as a library.

It's my understanding that GameClient was to have been deprecated as of February 7, 2014 but when looking at Google's sample code (e.g. ButtonClicker) it still uses this import and some of the method calls from the import.

I got the code I am using from Google's GitHub sample app repository for the ButtonClicker2000, some of that code has been recycled and used in the program I'm having errors with as well.

This is all the info I can think to provide, if anything more would help please let me know.

Was it helpful?

Solution

I was struggling with the ButtonClicker2000 example for a couple days and I was having the same problem as yours.

I think the problem in the sample code is having some lines being not updated. If you look at that page, you can easily see that the updated versions of those lines are lying there. However the codes in GitHub page are not updated completely.

Because GamesClient class is removed permanently, those statements

GamesClient.EXTRA_PLAYERS 
GamesClient.EXTRA_MIN_AUTOMATCH_PLAYERS 
GamesClient.EXTRA_MAX_AUTOMATCH_PLAYERS
GamesClient.EXTRA_INVITATION
GamesClient.STATUS_OK

must be replaced with

Games.EXTRA_PLAYERS_IDS
Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS
Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS
Multiplayer.EXTRA_INVITATION
GamesStatusCodes.STATUS_OK

Also that line can be removed:

import com.google.android.gms.games.GamesClient;

There is no need for importing GoogleApiClient because it is already imported in GameHelper.java.

After changing these lines manually and importing Multiplayer and GamesStatusCodes classes, I was successful to compile the code. I hope that solves your problem as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top