BaseGameUtils GoogleApiClient.ApiOptions cannot be allowed for type

After importing the BaseGameUtils project as a library and fixing several errors, I came across these errors:

GoogleApiClient.ApiOptions mGamesApiOptions = null; GoogleApiClient.ApiOptions mPlusApiOptions = null; GoogleApiClient.ApiOptions mAppStateApiOptions = null; 

errors say that GoogleApiClient.ApiOptions cannot be allowed for a type. Other errors I received:

 public void setGamesApiOptions(GoogleApiClient.ApiOptions options) { doApiOptionsPreCheck(); mGamesApiOptions = options; } 

they say that mGamesApiOptions cannot be resolved by the variable and is the same as before for GoogleApiClient.ApiOptions. I already referred to google_play_services_lib on GameBaseUtils. I looked on the Internet for some explanation without success, the only thing I found was https://code.google.com/p/google-api-java-client/wiki/Setup , but nothing helped because I didn I really understand what to do, can anyone help? (btw i use eclipse)

+6
source share
3 answers

ran into the same problem just now. This solution worked

Use the code here: https://gist.github.com/EmmanuelVinas/ef09a35bcc805ba6deb3

Just cut everything from the import of GameHelper.java (BaseGameUtils) to the end, and then paste the contents of this line as a replacement.

+10
source

I have the same problem with my application. I think they must have changed something in the latest update to GameHelper.java . Here I tried something, but so that you know, it only eliminates errors, so I could compile my code, it will not fix the source of the problem.

 // Api options to use when adding each API, null for none Games.GamesOptions mGamesApiOptions = null; Plus.PlusOptions mPlusApiOptions = null; Api.ApiOptions mAppStateApiOptions = null; 

I also changed the methods further down to make the classes fit ...

 /** * Sets the options to pass when setting up the Games API. Call before * setup(). */ public void setGamesApiOptions(Games.GamesOptions options) { doApiOptionsPreCheck(); mGamesApiOptions = options; } /** * Sets the options to pass when setting up the AppState API. Call before * setup(). */ public void setAppStateApiOptions(Api.ApiOptions options) { doApiOptionsPreCheck(); mAppStateApiOptions = options; } /** * Sets the options to pass when setting up the Plus API. Call before * setup(). */ public void setPlusApiOptions(Plus.PlusOptions options) { doApiOptionsPreCheck(); mPlusApiOptions = options; } 

I was still getting errors, so I finally had to get rid of the second parameters of these addApi() method calls because they did not accept these types of classes. Fortunately, the addApi() method does not need the options parameter, but removing it pretty much strikes the whole goal of having these variables in the first place.

 if (0 != (mRequestedClients & CLIENT_GAMES)) { builder.addApi(Games.API); //, mGamesApiOptions); builder.addScope(Games.SCOPE_GAMES); } if (0 != (mRequestedClients & CLIENT_PLUS)) { builder.addApi(Plus.API); //, mPlusApiOptions); builder.addScope(Plus.SCOPE_PLUS_LOGIN); } if (0 != (mRequestedClients & CLIENT_APPSTATE)) { builder.addApi(AppStateManager.API); //, mAppStateApiOptions); builder.addScope(AppStateManager.SCOPE_APP_STATE); } 

I really hope someone comes up with a real solution or updates the GameHelper file. This was a pretty nasty problem. Sorry, I could not be more helpful.

EDIT: I found when they changed this code in a GitHub project . However, these changes were made more than 3 months ago, so I am very confused about why someone else did not have this problem. Here's what it looks like:

 - // Client objects we manage. If a given client is not enabled, it is null. - GamesClient mGamesClient = null; - PlusClient mPlusClient = null; - AppStateClient mAppStateClient = null; + // the Google API client builder we will use to create GoogleApiClient + GoogleApiClient.Builder mGoogleApiClientBuilder = null; - // What clients we manage (OR-able values, can be combined as flags) + // Api options to use when adding each API, null for none + GoogleApiClient.ApiOptions mGamesApiOptions = null; + GoogleApiClient.ApiOptions mPlusApiOptions = null; + GoogleApiClient.ApiOptions mAppStateApiOptions = null; + + // Google API client object we manage. + GoogleApiClient mGoogleApiClient = null; 
+2
source

I was able to solve this problem by updating the latest BaseGameUtils library:

https://github.com/playgameservices/android-samples

0
source

Source: https://habr.com/ru/post/969811/


All Articles