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

标签 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();
}

最佳答案

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

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

如果您的应用程序在调试中工作。将用于发布 key 的 SHA 添加到您的 key 。

关于android - 在 Play 商店上传应用程序后,Google 登录无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38693135/

相关文章:

android - 如何在 Eclipse ADT 中停止 adb 进程?

java - 追加到文件 android

java - 在 Fragment 中使用 Google 登录按钮

ios - iPad 中的 Google 登录用户代理问题

Android:拖放问题

android - 如何在 Android 上更改默认的 ProgressBar 圆圈颜色

android - 在 Busybox 中模拟不良网络连接

android - 使用 com.google.gms.google-services gradle 插件时出现 NoSuchMethodError。

ios - 在 ios 中使用 sdk 时自定义谷歌登录按钮

iOS CocoaPod 警告 - "Google has been deprecated"- 使用 pod 'Google/SignIn' 时