问题
I´m trying to develop a real-time multiplayer game using google play game services and I download the sample(ButtonClicker2000), but Eclipse ADK keeps complaining that com.google.android.gms.games.GamesClient cannot be resolved.
All of the other imports work fine:
import com.google.android.gms.games.Games;
import com.google.android.gms.games.GamesActivityResultCodes;
import com.google.android.gms.games.multiplayer.Invitation;
import com.google.android.gms.games.multiplayer.OnInvitationReceivedListener;
import com.google.android.gms.games.multiplayer.Participant;
import com.google.android.gms.games.multiplayer.realtime.RealTimeMessage;
import com.google.android.gms.games.multiplayer.realtime.RealTimeMessageReceivedListener;
import com.google.android.gms.games.multiplayer.realtime.Room;
import com.google.android.gms.games.multiplayer.realtime.RoomConfig;
import com.google.android.gms.games.multiplayer.realtime.RoomStatusUpdateListener;
import com.google.android.gms.games.multiplayer.realtime.RoomUpdateListener;
import com.google.example.games.basegameutils.BaseGameActivity;
Does anyone know how to fix this?
回答1:
GamesClient was a part of the Google Play Services library - google-play-services.jar
.
In older versions, you could locate the class if you explore the library. In Eclipse it's probably under 'Android Private Libraries' in your package list. Go down the packages and search for com.google.android.gms.games.GamesClient
Since the Google Play services update to version 4.3, GamesClient is no longer available. You should switch to GoogleApiClient instead.
So if you update your packages from the Android SDK Manager, Google Play Services will be updated to revision 16, released on 17 March 2014. Since GamesClient
has been deprecated, it will be missing form the package after you restart Eclipse and refresh the workspace.
This is the official statement:
The previous Games client is deprecated as of February 7th, 2014. Existing and new developers are strongly encouraged to use GoogleApiClient instead of the deprecated GamesClient.:
So you either need to replace GamesClient with GoogleApiClient (better), or downgrade your google-play-service lib to the older version (not recommended).
In order to replace GamesClient, you will need to refactor the code. Here is the official announcement and introduction to the new API. Here is one example of an updated sample.
It's likely that the playgameservices samples will be updated, you can issue a ticket the github page of the project for that.
来源:https://stackoverflow.com/questions/22825940/com-google-android-gms-games-gamesclient-cannot-be-resolved