2014-05-22 3 views
2

Я использую Eclipse, LibGdx 1.0.1, Последние Google Play Lib и Последние BaseGameUtils от https://github.com/playgameservices/android-samplesошибки с помощью LibGdx с Google Play Services/BaseGameUtils (Gradle)

(Gradle Project)

Мои BaseGameUtils имеет несколько ошибок

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; 
} 

Поэтому я добавил //error with this line на линиях с вами догадались об ошибках.

Как я уже говорил, я считаю, что у меня есть последние библиотеки, и я уверен, что мои проекты связаны правильно. У меня также есть необходимые строки кода в файле AndroidManifest.xml.

ответ

1

Были некоторые изменения API в Google Play Game Services 4.4, которые еще не были отражены в проекте Android Samples (https://github.com/playgameservices/android-samples/tree/master/BasicSamples/libraries/BaseGameUtils) или задокументированы Google (насколько я знаю).

Посмотрите на комментарии к записи G + Android Developers:

https://plus.google.com/+AndroidDevelopers/posts/8957tqzymuM

Вы можете использовать сообщество модифицированного GameHelper, ждать Google, чтобы обновить образец проект или обратный ООБ 4,3.

+0

Человек, с которым я сошел с ума ... Надеюсь, он скоро будет обновлен. Thanks – WaZz

+0

Нет проблем. Пожалуйста, подтвердите ответ, если он решил проблему. – objitsu

+0

мой представитель не достаточно высок lol. Где я могу получить 4.3? – WaZz

0

Используйте код доступен здесь вместо: https://gist.github.com/EmmanuelVinas/ef09a35bcc805ba6deb3

Просто отрезать все от импорта GameHelper.java до конца его, а затем вставьте содержимое этой сущности в качестве замены.

работает

1

я использовал источник из https://github.com/playgameservices/android-samples/tree/master/BasicSamples/libraries/BaseGameUtils/src/main/java/com/google/example/games/basegameutils, но мое приложение разбился со следующей ошибкой:

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). 

Я изменил метод BaseGameActivity OnCreate:

@Override 
protected void onCreate(Bundle b) { 
    super.onCreate(b); 
    if (mHelper == null) { 
     getGameHelper(); 
    } 
    mHelper.setPlusApiOptions(new Plus.PlusOptions.Builder().build()); 
    mHelper.setup(this); 
} 

и ошибка исчезла.

+0

Это действительно сработало! –

Смежные вопросы