title: Google Play Sign in Failure Api Exception 4
body: <p>Im trying to integrate google sign in and took the code from another project that it works on, but for the new app it goes thru the log in but the dialog to allow doesnt show up and instead I get sign in failure with Api Exception 4.</p>
  
  <p>Here is all the applicable code:</p>
  
  <pre><code>//Create the client used to sign in to Google services
          mGoogleSignInClient = GoogleSignIn.getClient(this,
                  new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
                          .requestServerAuthCode(getString(R.string.client_id))
                          .requestEmail()
                          .build());
  private void signInSilently(){
          Log.d(TAG, "signInSilently()");
  
          mGoogleSignInClient.silentSignIn().addOnCompleteListener(this,
                  new OnCompleteListener&lt;GoogleSignInAccount&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;GoogleSignInAccount&gt; task) {
                          if (task.isSuccessful()) {
                              Log.d(TAG, "signInSilently(): success");
  
                              onConnected(task.getResult());
                          } else {
                              Log.d(TAG, "signInSilently(): failure", task.getException());
                              onDisconnected();
                          }
                      }
                  });
      }
  
      private void startSignInIntent() {
          startActivityForResult(mGoogleSignInClient.getSignInIntent(), RC_SIGN_IN);
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if (requestCode == RC_SIGN_IN) {
              Task&lt;GoogleSignInAccount&gt; task =
                      GoogleSignIn.getSignedInAccountFromIntent(data);
  
              try {
                  GoogleSignInAccount account = task.getResult(ApiException.class);
                  onConnected(account);
              } catch (ApiException apiException) {
                  String message = apiException.getMessage();
                  if (message == null || message.isEmpty()) {
                      message = getString(R.string.signin_other_error);
                  }
  
                  onDisconnected();
  
                  new AlertDialog.Builder(this)
                          .setMessage(message)
                          .setNeutralButton(android.R.string.ok, null)
                          .show();
              }
          }
      }
  private void onDisconnected() {
          Log.d(TAG, "onDisconnected()");
  
          mPlayersClient = null;
          // Show sign-in button on main menu
          if(game.user != null) {
              game.user.setDisplayName(null);
              game.user.setPlayerID(null);
          }
      }
  
      private void onConnected(final GoogleSignInAccount googleSignInAccount) {
          Log.d(TAG, "onConnected(): connected to Google APIs");
  
          GamesClient gamesClient = Games.getGamesClient(AndroidLauncher.this, googleSignInAccount);
          View view = ((AndroidGraphics) Gdx.graphics).getView();
          gamesClient.setViewForPopups(view);
          gamesClient.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
  
          mPlayersClient = Games.getPlayersClient(this, googleSignInAccount);
  
          // Set the greeting appropriately on main menu
          mPlayersClient.getCurrentPlayer()
                  .addOnCompleteListener(new OnCompleteListener&lt;Player&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;Player&gt; task) {
                          String displayName;
                          if (task.isSuccessful()) {
                              user = new User();
                              user.setDisplayName(task.getResult().getDisplayName());
                              user.setPlayerID(task.getResult().getPlayerId());
                              game.user = user;
                              firebaseAuthWithPlayGames(googleSignInAccount);
                          } else {
                              Exception e = task.getException();
                              handleException(e, getString(R.string.players_exception));
                              displayName = "???";
                          }
                      }
                  });
      }
  
      private void handleException(Exception e, String details) {
          int status = 0;
  
          if (e instanceof ApiException) {
              ApiException apiException = (ApiException) e;
              status = apiException.getStatusCode();
          }
  
          String message = getString(R.string.status_exception_error, details, status, e);
  
          new AlertDialog.Builder(AndroidLauncher.this)
                  .setMessage(message)
                  .setNeutralButton(android.R.string.ok, null)
                  .show();
      }
  </code></pre>