选择帐户后,flutter google 登录卡住加载

Moh*_*nab 6 android google-authentication flutter

我尝试先使用谷歌登录,我的信息我选择了谷歌帐户,它卡在加载中,没有任何响应,甚至没有任何与之相关的控制台消息,这是我的代码

 GoogleSignInAccount _currentUser;
GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [
  'email',
  'https://www.googleapis.com/auth/cloud-platform.read-only',
],
);
 @override
void initState() {
super.initState();
_googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount account) {
  setState(() {
    _currentUser = account;
  });
});
_googleSignIn.signInSilently();
}

Future<void> _googlelogin() async {
  try {
    final GoogleSignInAccount googleSignInAccount =
        await _googleSignIn.signIn();
    final GoogleSignInAuthentication googleSignInAuthentication =
        await googleSignInAccount.authentication;
  } catch (error) {
    print(error);
  }
}

....

 RaisedButton(
      onPressed: () {
       _googlelogin();
      },),
                        ), 
Run Code Online (Sandbox Code Playgroud)

预览正在发生的事情

预览截图

控制台中消息的预览(如果相关) 消息

reh*_*001 1

  1. 我删除了 firebase 控制台上的应用程序,创建了新的应用程序。
  2. 我在 firebase 项目级别设置中添加了 SHA-1、SHA256 指纹。
  3. 我还在项目级别设置的“支持电子邮件”字段中选择了我的电子邮件 ID。
  4. 我按照@Abdelazeem 的建议com.google.gms:google-services穿上了。build.gradle

他们都不为我工作。每次我选择 Gmail 帐户时,它都会无限期地加载,并且控制台中也没有打印任何重要信息。

但这对我有用

pubspec.yaml

  dependencies:
    firebase_core: ^1.7.0
    firebase_auth: ^3.1.2
    googleapis: ^5.0.1
    google_sign_in: ^5.1.1
Run Code Online (Sandbox Code Playgroud)

AuthenticationService.dart

  dependencies:
    firebase_core: ^1.7.0
    firebase_auth: ^3.1.2
    googleapis: ^5.0.1
    google_sign_in: ^5.1.1
Run Code Online (Sandbox Code Playgroud)