Why everytime connection is failed by Google LogIn?
<p>I've implemented Google <strong>LogIn</strong> and it is working, but now this code don't work and really can't understand why I'm getting <strong>connection is failed</strong>  error ?</p>
<p>Help me to solve it please</p>
<p><strong>there is snippet of implementation</strong></p>
<pre><code>public GoogleImplementation(Context context, AuthorizationActivity authorizationActivity) {
    this.context = context;
    this.authorizationActivity = authorizationActivity;

    googleApiClient = new GoogleApiClient.Builder(context)
            .addConnectionCallbacks(connectionCallbacks)
            .addOnConnectionFailedListener(connectionFailedListener)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .build();
}

GoogleApiClient.OnConnectionFailedListener connectionFailedListener =
        new GoogleApiClient.OnConnectionFailedListener(){
            /**
             * Check if Google connected failed
             **/
            @Override
            public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

                Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 10&quot;);


                if (!connectionResult.hasResolution()) {

                    Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 11&quot;);


                    Log.e(MY_LOG, &quot;user have tried to logIn with Google but onConnectionFailed&quot;);
                    GooglePlayServicesUtil.getErrorDialog(
                            connectionResult.getErrorCode(), authorizationActivity, 0).show();
                    return;
                }

                if (!AuthorisationHelper.isIntentInProgress()) {

                    Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 12&quot;);

                    // Store the ConnectionResult for later usage
                    AuthorisationHelper.setConnectionResult(connectionResult);

                    if (AuthorisationHelper.isSignInClicked()) {

                        Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 13&quot;);

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

        };
</code></pre>
<p>For debug I  am using <code>Log()</code> and I noticed that every time when I came to screen with Google button immediately I get Log</p>
<blockquote>
<p>Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 10&quot;);</p>
<p>Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 12&quot;);</p>
</blockquote>
<p>but I don't click any button...</p>
<p>Ok, it was just for information</p>
<p>Next when I click <strong>Google</strong> button pop-up with available accounts is display and I select my account, and nothing happens, I just get again Log</p>
<blockquote>
<p>Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 10&quot;);</p>
<p>Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 12&quot;);</p>
</blockquote>
<p>that mean i get connection is failed...</p>
<p>What I am doing wrong?</p>
<p><strong>Full class with implementation</strong></p>
<pre><code>public class GoogleImplementation {

private static final String MY_LOG = &quot;GoogleImplementation&quot;;
private Context context;
private static GoogleApiClient googleApiClient;
private AuthorizationActivity authorizationActivity;

public GoogleImplementation(Context context, AuthorizationActivity authorizationActivity) {
    this.context = context;
    this.authorizationActivity = authorizationActivity;

    googleApiClient = new GoogleApiClient.Builder(context)
            .addConnectionCallbacks(connectionCallbacks)
            .addOnConnectionFailedListener(connectionFailedListener)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .build();
}

@NonNull
public GoogleApiClient getGoogleApiClient() {
    return googleApiClient;
}

GoogleApiClient.ConnectionCallbacks connectionCallbacks =
        new GoogleApiClient.ConnectionCallbacks(){
            /**
             * Check if Google connected success
             **/
            @Override
            public void onConnected(Bundle bundle) {

                Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! onConnected&quot;);


                Log.e(MY_LOG, &quot;User is connecting by Google LogIn&quot;);

                if (isCurrentPersonNull()) return;
                getUsreGoogleData();
                if (isPersonIdNull()) return;
                chooseNextFrame();
            }

            /**
             * Check if Google connected suspended
             **/
            @Override
            public void onConnectionSuspended(int i) {
                Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 9&quot;);

                googleApiClient.connect();
            }
        };

GoogleApiClient.OnConnectionFailedListener connectionFailedListener =
        new GoogleApiClient.OnConnectionFailedListener(){
            /**
             * Check if Google connected failed
             **/
            @Override
            public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

                Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 10&quot;);


                if (!connectionResult.hasResolution()) {

                    Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 11&quot;);


                    Log.e(MY_LOG, &quot;user have tried to logIn with Google but onConnectionFailed&quot;);
                    GooglePlayServicesUtil.getErrorDialog(
                            connectionResult.getErrorCode(), authorizationActivity, 0).show();
                    return;
                }

                if (!AuthorisationHelper.isIntentInProgress()) {

                    Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 12&quot;);

                    // Store the ConnectionResult for later usage
                    AuthorisationHelper.setConnectionResult(connectionResult);

                    if (AuthorisationHelper.isSignInClicked()) {

                        Log.e(&quot;!!!!!!!!!!!!!!!!!&quot;, &quot;!!!!!!!!!!!!!!!! 13&quot;);

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

        };

private boolean isCurrentPersonNull() {
    if (Plus.PeopleApi.getCurrentPerson(googleApiClient) == null) {
        Log.e(MY_LOG, &quot;AuthorizationActivity : Person information is null&quot;);
        return true;
    }
    return false;
}

private void getUsreGoogleData() {
    try {
        AuthorisationHelper.setSignInClicked(false);
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(googleApiClient);
        String personPhotoUrl = currentPerson.getImage().getUrl();
        String personGooglePlusProfile = currentPerson.getUrl();
        AuthorisationHelper.setPersonId(currentPerson.getId());
        String personEmail = Plus.AccountApi.getAccountName(googleApiClient);
        AuthorisationHelper.setPersonEmail(personEmail);

        /** by default the profile url gives 50x50 px image only
         * we can replace the value with whatever dimension we want by
         * replacing sz=X
         * */
        personPhotoUrl = personPhotoUrl.substring(0,
                personPhotoUrl.length() - 2)
                + 400;

    } catch (Exception e) {
        e.printStackTrace();
    }
}

private boolean isPersonIdNull() {
    if (UtilClass.isTextEmpty(AuthorisationHelper.getPersonId())) {
        Log.e(MY_LOG, &quot;User id from google is null&quot;);
        UtilClass.showDialog(authorizationActivity.getFragmentManager(), new CallBackDialog());
        return true;
    }
    return false;
}
}
}
</code></pre>