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();
}
}
ベストアンサー1
引用:ドキュメンテーション:
特定の Google Play サービス(Google ログインやアプリ招待など)では、アプリ用の OAuth2 クライアントと API キーを作成できるように、署名証明書の SHA-1 を提供する必要があります。
を使用している場合はFirebase
、以下を試してくださいdebug app
。
1. まず、SHA-1
デバッグキーを取得します。
- クリックします
Gradle
(右側のパネルにGradleバーが表示されます) - クリック
Tasks
- クリック
Android
- ダブルクリックします
signingReport
(とが表示されSHA-1
ますMD5
)
2. プロジェクトにキーを追加しますFirebase
。
Project settings
->SHA certificate fingerprints
->SHA-1
デバッグ アプリのキーの追加に移動します。google-services.json
その後、 Android プロジェクト内のファイルを更新できます。
私にとってはうまくいきます。