在Android中使用Google登录时出现晦涩的错误 [英] Getting obscure error when using Google sign-in in Android

查看:117
本文介绍了在Android中使用Google登录时出现晦涩的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用

I'm getting com.google.android.gms.common.api.ApiException: 10: when trying to use Google sign-in.

这是代码本身:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        // The Task returned from this call is always completed, no need to attach
        // a listener.
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        //handleSignInResult(task);
        GoogleSignInAccount account = getAccount(task);
        System.out.println("asti00");
    }
}

public GoogleSignInAccount getAccount(Task<GoogleSignInAccount> task) {
    GoogleSignInAccount account = null;
    try {
        account = task.getResult(ApiException.class);
    } catch (ApiException ex) {
        // TODO: handle exception
        System.out.println("asti01");
        System.out.println("MESSAGE: " + ex.getMessage());
        ex.printStackTrace();
        System.out.println("asti02");
    }

    return account;
}

如您所见,我正在使用与教程,但出现错误com.google.android.gms.common.api.ApiException: 10:.

As you can see I'm using the exact code as in the tutorial but I'm getting the error com.google.android.gms.common.api.ApiException: 10:.

我不知道错误是从哪里来的.谁能帮我吗?

I can't figure out where the error is coming from. Can anyone please help me?

谢谢

推荐答案

您的应用未链接到您的Google帐户.单击工具-> Firebase->身份验证,然后执行教程(所有步骤).之后,再试一次.

Your app is not linked to your Google Account. Click on Tools -> Firebase -> Authentication and execute the tutorial (all steps). After that, try again.

这篇关于在Android中使用Google登录时出现晦涩的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆