private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class); //exception is here
// Signed in successfully, show authenticated UI.
System.out.println("google token ---> " + account.getIdToken());
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information about this error.
e.printStackTrace();
}
}
最佳答案
引用 documentation :
Certain Google Play services (such as Google Sign-in and App Invites) require you to provide the SHA-1 of your signing certificate so we can create an OAuth2 client and API key for your app.
如果您使用的是 Firebase
并尝试使用 debug app
:
1.首先,获取您的 SHA-1
调试 key :
- 点击
Gradle
(从右侧面板,你会看到Gradle Bar) - 点击
任务
- 点击
Android
- 双击
signingReport
(你会得到SHA-1
和MD5
)
<强>2。将您的 key 添加到您的 Firebase
项目:
进入
项目设置
->SHA证书指纹
-> 添加调试应用的SHA-1
键。然后您可以在您的 Android 项目中更新您的
google-services.json
文件。
它对我有用。
关于android - 为什么我会收到 com.google.android.gms.common.api.ApiException : 10:?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47437678/