Getting obscure error when using Google sign-in in Android

给你一囗甜甜゛ 提交于 2019-12-12 04:46:38

问题


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

Here is the code itself:

@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;
}

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?

Thanks


回答1:


Try to add to your app level build.gradle

compile 'com.google.android.gms:play-services-auth:9.8.0'




回答2:


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



来源:https://stackoverflow.com/questions/47277411/getting-obscure-error-when-using-google-sign-in-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!