Skip to content Skip to sidebar Skip to footer

How To Fix Boolean Com.google.android.gms.common.connectionresult.hasresolution() Null Reference In G+ On Android

I want use Google Plus account for Sign-in in my Application. I write this codes, but show me Force close error. MainActivity codes: public class MainActivity extends AppCompatActi

Solution 1:

Your field mConnectionResult can be null, which is causing the app to throw a NullPointerException when it attempts to access it.

The solution is to change your processing of onConnectionFailed so that it always assigns a value to your variable before you access it.

@OverridepublicvoidonConnectionFailed(ConnectionResult result) {
    // Always assign result first
    mConnectionResult = result;

    if (!result.hasResolution()) {
        GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this,
                0).show();
        return;
    }

    if (!mIntentInProgress) {

        if (mSignInClicked) {
            // The user has already clicked 'sign-in' so we attempt to// resolve all// errors until the user is signed in, or they cancel.resolveSignInError();
        }
    }
}

Post a Comment for "How To Fix Boolean Com.google.android.gms.common.connectionresult.hasresolution() Null Reference In G+ On Android"