问题
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