FireBase Android登录演示不工作

FireBase Android登录演示不工作,android,google-signin,firebase-authentication,Android,Google Signin,Firebase Authentication,有人使用过Firebase和Google登录演示吗 我尝试了一下,它编译得很好,但当我按下Google登录按钮,选择我的个人资料时,我在ActivityResult结果上得到的回调。isSuccess为false /* ************************************* * GOOGLE * ***************************************/ /* Load the Google

有人使用过Firebase和Google登录演示吗

我尝试了一下,它编译得很好,但当我按下Google登录按钮,选择我的个人资料时,我在ActivityResult结果上得到的回调。isSuccess为false

/* *************************************
*               GOOGLE                *
***************************************/

/* Load the Google login button */
mGoogleLoginButton = (SignInButton) findViewById(R.id.login_with_google);
mGoogleLoginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            startActivityForResult(signInIntent, RC_GOOGLE_LOGIN);
        }
    });

/* Setup the Google API object to allow Google logins */
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestEmail()
        .build();

mGoogleApiClient = new GoogleApiClient.Builder(this)
        .enableAutoManage(this, this)
        .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
        .build();
在下面为结果回调启动活动:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_GOOGLE_LOGIN) {
        /* This was a request by the Google API */
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            GoogleSignInAccount acct = result.getSignInAccount();
            String emailAddress = acct.getEmail();
            getGoogleOAuthTokenAndLogin(emailAddress);
        }
    } else {
        Log.d(TAG, " Sign in Result is not success");
    }
}

我是否需要在谷歌控制台API上为此创建一个项目以及该项目的配置文件,才能使其正常工作?

我昨天遇到了同样的问题。这个例子似乎过时了。我无法使用提供的代码找到解决方案。但是有一种更直观的方法,您可以在官方文档中找到更少的代码