Reputation: 82
I am using Eclipse, LibGdx 1.0.1, Latest Google Play Lib, and Latest BaseGameUtils from https://github.com/playgameservices/android-samples
(Gradle Project)
My BaseGameUtils has a few errors
GameHelper.java
// Api options to use when adding each API, null for none
GoogleApiClient.ApiOptions mGamesApiOptions = null; //error with this line
GoogleApiClient.ApiOptions mPlusApiOptions = null; //error with this line
GoogleApiClient.ApiOptions mAppStateApiOptions = null; //error with this line
/**
* Sets the options to pass when setting up the Games API. Call before
* setup().
*/
public void setGamesApiOptions(GoogleApiClient.ApiOptions options) { //error with this line
doApiOptionsPreCheck();
mGamesApiOptions = options; //error with this line
}
/**
* Sets the options to pass when setting up the AppState API. Call before
* setup().
*/
public void setAppStateApiOptions(GoogleApiClient.ApiOptions options) { //error with this line
doApiOptionsPreCheck();
mAppStateApiOptions = options; //error with this line
}
/**
* Sets the options to pass when setting up the Plus API. Call before
* setup().
*/
public void setPlusApiOptions(GoogleApiClient.ApiOptions options) { //error with this line
doApiOptionsPreCheck();
mPlusApiOptions = options; //error with this line
}
/**
* Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
* you do not have to do this; use this method only if you need to make
* nonstandard setup (e.g. adding extra scopes for other APIs) on the
* GoogleApiClient.Builder before calling @link{#setup}.
*/
public GoogleApiClient.Builder createApiClientBuilder() {
if (mSetupDone) {
String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
+ "calling setup. You can only get a client builder BEFORE performing setup.";
logError(error);
throw new IllegalStateException(error);
}
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
mActivity, this, this);
if (0 != (mRequestedClients & CLIENT_GAMES)) {
builder.addApi(Games.API, mGamesApiOptions); //error with this line
builder.addScope(Games.SCOPE_GAMES);
}
if (0 != (mRequestedClients & CLIENT_PLUS)) {
builder.addApi(Plus.API, mPlusApiOptions); //error with this line
builder.addScope(Plus.SCOPE_PLUS_LOGIN);
}
if (0 != (mRequestedClients & CLIENT_APPSTATE)) {
builder.addApi(AppStateManager.API, mAppStateApiOptions); //error with this line
builder.addScope(AppStateManager.SCOPE_APP_STATE);
}
mGoogleApiClientBuilder = builder;
return builder;
}
So I added //error with this line
on the lines with you guessed it errors.
Like I mentioned before I believe that I have the latest libraries, and I am sure my projects are linked correctly. I also have the necessary lines of code in my AndroidManifest.xml
file.
Upvotes: 2
Views: 1442
Reputation: 1301
I used source from https://github.com/playgameservices/android-samples/tree/master/BasicSamples/libraries/BaseGameUtils/src/main/java/com/google/example/games/basegameutils but my application crashed with following error:
java.lang.NullPointerException: Null options are not permitted for this Api at
.. com.google.example.games.basegameutils.GameHelper.createApiClientBuilder(GameHelper.java:286 ) at
com.google.example.games.basegameutils.GameHelper.setup(GameHelper.java:319) at
com.google.example.games.basegameutils.BaseGameActivity.onCreate(BaseGameActivity.java:105).
I have changed BaseGameActivity onCreate method:
@Override
protected void onCreate(Bundle b) {
super.onCreate(b);
if (mHelper == null) {
getGameHelper();
}
mHelper.setPlusApiOptions(new Plus.PlusOptions.Builder().build());
mHelper.setup(this);
}
and error disappeared.
Upvotes: 1
Reputation: 3134
Use the code available here instead: https://gist.github.com/EmmanuelVinas/ef09a35bcc805ba6deb3
Just cut everything from the imports of GameHelper.java to the end of it and then paste the contents of that gist as a replacement.
it works
Upvotes: 0
Reputation: 126
There's been some API changes on Google Play Game Services 4.4 that have not yet been reflected on the Android Samples project (https://github.com/playgameservices/android-samples/tree/master/BasicSamples/libraries/BaseGameUtils) or documented by Google (as far as I know).
Have a look to the comments on G+ Android Developers entry:
https://plus.google.com/+AndroidDevelopers/posts/8957tqzymuM
You can either use the community modified GameHelper, wait for Google to update the sample project or reverse to GPGS 4.3.
Upvotes: 1