Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null options are not permitted for this Api #78

Closed
ar2rsawseen opened this issue Jun 6, 2014 · 7 comments
Closed

Null options are not permitted for this Api #78

ar2rsawseen opened this issue Jun 6, 2014 · 7 comments

Comments

@ar2rsawseen
Copy link

Keep getting:

FATAL EXCEPTION: main java.lang.NullPointerException: Null options are not permitted for this Api at com.google.android.gms.internal.fq.b(Unknown Source) at com.google.android.gms.common.api.GoogleApiClient$Builder.addApi(Unknown Source) at com.giderosmobile.android.plugins.googleplaygame.GameHelper.createApiClientBuilder(GameHelper.java:286)

the fix seems to be, not passing mPlusOptions

if (0 != (mRequestedClients & CLIENT_PLUS)) {
            if(mPlusApiOptions != null)
                builder.addApi(Plus.API, mPlusApiOptions);
            else
                builder.addApi(Plus.API);
            builder.addScope(Plus.SCOPE_PLUS_LOGIN);
}

Is this a problem in my code, or something changes in Google Play Services?

@dinosoeren
Copy link

At the beginning of the GameHelper class, you instantiate mPlusApiOptions and define it as null, so there's no reason it would pass anything else.

    // Api options to use when adding each API, null for none
    GamesOptions mGamesApiOptions = GamesOptions.builder().build();
    PlusOptions mPlusApiOptions = null;
    NoOptions mAppStateApiOptions = null;

@ar2rsawseen
Copy link
Author

@swalls yes I understand that, my question would be, why it seems that nobody but me is having this problem, if it is done in GameHelper by default?

@dinosoeren
Copy link

@ar2rsawseen Oh, sorry. I assumed you knew you're not the only one getting it. I got the same NullPointerException once I declared this in my extending class:

public AndroidGame() {
     super(BaseGameActivity.CLIENT_ALL);
}

And I subsequently had to remove mPlusApiOptions from the .addApi declaration in order for my code to work again. Before declaring CLIENT_ALL, it was working fine for some reason. But I needed to integrate more than just the GAMES api at that point.

@gguuss gguuss closed this as completed Jun 9, 2014
@gguuss gguuss reopened this Jun 9, 2014
@gguuss
Copy link
Contributor

gguuss commented Jun 9, 2014

I'll look into this the issue: I have seen in recent updates that if you pass null as ApiOptions, it can break. The fix is to initialize ApiOptions.

@mpost
Copy link

mpost commented Jun 22, 2014

Just wanted to chim that i have the same NPE issue. I am using CLIENT_ALL as well and am now declaring the PlusOptions by default:

PlusOptions mPlusApiOptions = PlusOptions.builder().build();

@mpost
Copy link

mpost commented Jul 14, 2014

The current version has simply removed to pass the plusOptions. That is probably bad since the method setPlusApiOptions(..) is now broken.

@gguuss
Copy link
Contributor

gguuss commented Aug 13, 2014

You need to add the APIs you are using in the API client builder along with the identifier for the API and not null, for example:

    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
            mActivity, this, this);
        builder.addApi(Games.API, mGamesApiOptions);
        builder.addScope(Games.SCOPE_GAMES);
        builder.addApi(Plus.API);
        builder.addScope(Plus.SCOPE_PLUS_LOGIN);

    mGoogleApiClientBuilder = builder;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants