Google Play Services GameHelper NPE createApiClientBuilder (Null options are not permitted for this API)

StackOverflow https://stackoverflow.com//questions/24021320

Domanda

Since the latest Google Play Services and Android Studio update (0.5.9) I get this annoying error. When I start an activity with GameHelper the app crashes. These errors are the reason I loose my interest in making apps. I have the latest version of GameHelper from Googles GitHub page.

ACTIVITY:

mmmHelper = new GameHelper(this, GameHelper.CLIENT_ALL);

GameHelper.GameHelperListener listener = new GameHelper.GameHelperListener() {
            @Override
            public void onSignInSucceeded() {
                // handle sign-in succeess
            }
            @Override
            public void onSignInFailed() {
                // handle sign-in failure (e.g. show Sign In button)
            }

        };
        mmmHelper.setup(listener);


        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Games.API)
                .build();
        mGoogleApiClient.connect();

        Log.d(TAG, "Starting setup.");
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                Log.d(TAG, "Setup finished.");

                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    Log.d(TAG, "Problem setting up In-app Billing: " + result);
                }
                // Hooray, IAB is fully set up!
                mHelper.queryInventoryAsync(mGotInventoryListener);
            }
        });
È stato utile?

Soluzione

I fixed the crash by changing CLIENT_ALL to CLIENT_GAMES!

problem:

mmmHelper = new GameHelper(this, GameHelper.CLIENT_ALL);

fresh:

mmmHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);

I'm only using Games.API, so that might be the reason why the app crashed with CLIENT_ALL.

mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Games.API)
                .build();
mGoogleApiClient.connect();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top