在Play商店上传应用程序后,Google登录无法正常工作

时间:2016-08-01 07:25:34

标签: android google-signin

Google登录在上传到Play商店之前工作正常,但在将应用上传到商店后,google登录无效,并且在handleSignInResult()方法中返回始终为false。

以下是使用的代码:

 try {
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                // .requestEmail()
                .requestIdToken(getString(R.string.server_client_id))
                .requestEmail()
                // .requestScopes(new Scope(Scopes.DRIVE_APPFOLDER))
                // .requestServerAuthCode(getString(R.string.server_client_id), false)
                .build();
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                .enableAutoManage(getActivity() /* FragmentActivity */, this /* OnConnectionFailedListener */)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();
    } catch (IllegalStateException e) {
        Log.e("IllegalStateException ", e.toString());
    }

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);


    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_GET_TOKEN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);
    }


}
  private void handleSignInResult(GoogleSignInResult result) {
    Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
}

1 个答案:

答案 0 :(得分:1)

您必须更新Google Developer Console API。 内部凭证:

https://console.developers.google.com/apis/

如果您的应用程序在调试中工作。将SHA for release key添加到您的密钥。