English 中文(简体)
谷歌流星 不工作。 账户选择后停止
原标题:Flutter Firebase Google Sign In not working. Stops after account selection

我目前正在设法在我的服饰中实施角球标志和认证。 我设立了一个项目,并建立了一个消防基地,把 go光服务投入使用。 json in the application, supplemented the necessary plugin tobuilding.gradle, and set the SHA-1 key in firebase. 电子邮件认证工作十分出色,但信道认证造成问题。

所有认证都是由我制作的认证包完成的。 它包含一个认证网页,并具有完全的逻辑。 正在运行的主要冲碎 app,进口这一包裹供使用。 这一主要项目正在建设。 梯度文档中增加了 go角服务金(com.google.gms:google-services:4.3.2)。 主要项目一旦投入运行,如果用户目前被搁置起来,则会对其进行检查。 如果它不控制认证包,显示一个 au屏和处理标识。

这个问题是在选择我想要与时俱进的古角账户之后发生的。 一旦选定账户,账户选择方言就关闭了,此后没有发生。 用户不作认证(经过确认的消防基地),不作例外处理,围绕所有物体的尝试捕获物也不例外。 似乎所有职能的执行都停止。 我仍然可以穿透镜头,但用手法填写的标志永远无法完成执行。

您可以找到以下方法。 在实施“<条形码>后,谷歌星汇/海法>的执行不会因某种原因继续。

///
  Future<String> _signUpWithGoogle() async {
    bool isLoggedIn = await _firebaseAuth.isLoggedIn();
    if (!isLoggedIn) {
      googleSignIn = GoogleSignIn();
      final GoogleSignInAccount googleSignInAccount =
          await googleSignIn.signIn();
      final GoogleSignInAuthentication googleSignInAuthentication =
          await googleSignInAccount.authentication;

      final AuthCredential credential = GoogleAuthProvider.getCredential(
        accessToken: googleSignInAuthentication.accessToken,
        idToken: googleSignInAuthentication.idToken,
      );

      final AuthResult authResult =
          await _firebaseAuth.signInWithCredential(credential);
      final FirebaseUser user = authResult.user;

      assert(!user.isAnonymous);
      assert(await user.getIdToken() != null);

      final FirebaseUser currentUser = await _firebaseAuth.getUser();
      assert(user.uid == currentUser.uid);

      return  signInWithGoogle succeeded: $user ;
    } else {
      FirebaseUser user = await _firebaseAuth.getUser();
      return  signInWithGoogle succeeded: $user ;
    }
  }

我认为,如果出现错误,就应当重新接受《纲要》,但第一次没有例外。 如果我再次在方法上打上 go角,我就认为:

PlatformException(error, Concurrent operations detected: signIn, signIn, null)

下面你还可以找到主要仪器和认证包的附属条件:

主要受扶养人

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2
  permission:
  intl_translation:
  flutter_svg:
  sqflite:
  path:
  path_provider:
  uuid:
  qr_flutter:
  vibration:
  reflectable:
  provider:
  launcher_module:
    path: ../modules/launcher_module
  individual:
    path: ../modules/individual
  common:
    path: ../packages/common
  persistence:
    path: ../packages/persistence
  resources:
    path: ../packages/resources
  authentication:
    path: ../packages/authentication
  screen:
  flutter_screen_scaler: ^0.0.1
  page_indicator:
  toast: ^0.1.5
  rxbus: ^0.0.2
  shared_preferences:

1. 认证一揽子要求

dependencies:
  flutter:
    sdk: flutter
  firebase_auth: ^0.15.3+1
  google_sign_in: ^4.1.1
  flutter_facebook_login:
  shared_preferences:
  common: 
    path: "../common"
  toast: ^0.1.5

我也试图把所有认证逻辑移入主要评标,删除了对认证包的提及。 然而,这种情况仍然存在。

在所有这一切中,我是否做过错或失踪?

最佳回答

仅将我先前的评论变为正式答复:

<>Initial comment:

似乎与上述法典没有什么错误。 我的法典几乎完全相同,其文本是google_sign_in plugin/。 我将做些什么是贬低 p原的本地法典,以便弄清它 where在哪里,然后理解为什么会发生这种情况。 鉴于你提到的,在快速浏览原始代码后,在选择账户与Flutter签署并寄回其结果时,在onActativeResult之间肯定会 st。

www.un.org/Depts/DGACM/index_spanish.htm 提交人答复后:

由此可见,提交人对启动活动做了定制,因此,onActativeResult不再打上super.onActativeResult,从而阻止了google_sign_inplugin从本地方面向波兹特一侧发送数据。

当发射<代码>Intent <>Intent,即用于返还数据时,如申请许可,或带不同的照片。

问题回答

I had the same issue - it looks like we re working from the same tutorial (I m new at this too). For me, the problem was the SHA certificate fingerprints in Firebase - if you haven t set them up then the sign in simply won t do anything. In the terminals tab I could see that sign-in simply cancels itself.

为了解决这个问题,我这样做了:

  • Set up my Key file (keystore - yes initially I forgot to do this!)
  • Added my keystore file to the Android folder
  • Created a key.properties file in Android/app/ folder
  • Added my dependencies for the file in Android/app/build.gradle
  • From terminal window run android/gradlew.bat
  • Then in the same window run "gradlew signingReport" - this will give you SHA1 and SHA256 keys
  • Go in to firebase console, project, settings, general, andorid apps and enter the SHA certificate fingerprints that grade gave you.

然后重建,它应该发挥作用。

在我的案件中,我在4个月前增加了消防基地的关键点,现在我试图做一些改动,但不能签署。

而且,如果你不使用安乐施室及其数据,但只保留密码,那么情况也会发生,现在,你需要重新生成你 de的钥匙,并将其添加到火库中。

<代码>现在,所需步骤是创建新的脱硫钥匙,添加到火基上。

<>说明:在许多情况下,这不是主要原因,而是给它一个尝试<>。

In my case, I have forgot to add dependency at project-level build.gradle and app-level. When adding android and ios app through Firebase CLI.

“enterography

Make Sure to add this at Project-level Building. 梯度

“enterography

and At app-level build.gradle

“entergraph

对我来说,问题在于,在消防基地,我确实掌握了谷歌手语。 我正在醒来,使我能够选择我的直角账户。

final googleUser = await GoogleSignIn().signIn();

在我点击我的用户名后,我似乎停止了工作。 当我能够让谷歌在消防基地上签字时,一切都开始工作。

“enterography

I had the same error and the code was correct, and it s strange that it didn t work on android, it was fixed by the fact that I added SHA certificate fingerprints to firebase for this application, if anything, a link with a guide how to do it a link with a guide how to do it

<>strong>auth.dart

import  dart:io ;

import  package:cloud_firestore/cloud_firestore.dart ;
import  package:flutter/material.dart ;
import  package:flutter/services.dart ;
import  package:firebase_auth/firebase_auth.dart ;
import  package:fluttertoast/fluttertoast.dart ;
import  package:google_sign_in/google_sign_in.dart ;
import  package:shared_preferences/shared_preferences.dart ;

abstract class BaseAuth {

  Future<String> signInWithGoogle();

//optional if you need to store user data
  String name = "User";
  String email = "Demo";
  String imageUrl = "https://celebritypets.net/wp-content/uploads/2016/12/Adriana-Lima.jpg";


}
enum authProblems { UserNotFound, PasswordNotValid, NetworkError }

class Auth implements BaseAuth {

final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = GoogleSignIn();

  Future<String> signInWithGoogle() async {


  final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
  final GoogleSignInAuthentication googleSignInAuthentication =
      await googleSignInAccount.authentication;

  final AuthCredential credential = GoogleAuthProvider.getCredential(
    accessToken: googleSignInAuthentication.accessToken,
    idToken: googleSignInAuthentication.idToken,
  );

  final AuthResult authResult = await _firebaseAuth.signInWithCredential(credential);
  final FirebaseUser user = authResult.user;

  // Checking if email and name is null
  assert(user.email != null);
  assert(user.displayName != null);
  assert(user.photoUrl != null);

  name = user.displayName;
  email = user.email;
  imageUrl = user.photoUrl;


  // Only taking the first part of the name, i.e., First Name
  if (name.contains(" ")) {
    name = name.substring(0, name.indexOf(" "));
  }

  assert(!user.isAnonymous);
  assert(await user.getIdToken() != null);

  final FirebaseUser currentUser = await _firebaseAuth.currentUser();
  assert(user.uid == currentUser.uid);

  return  signInWithGoogle succeeded: $user ;
}

authprovider.dart

import  package:flutter/material.dart ;
import  package:multitask_flutter/auth.dart ;

class AuthProvider extends InheritedWidget {

  AuthProvider({Key key,Widget child, this.auth}) : super(key: key,child: child);
  final BaseAuth auth;


  @override
  bool updateShouldNotify(InheritedWidget oldWidget) => true;

  static AuthProvider of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<AuthProvider>();
  }

}

loginpage.dart

import  package:appname_flutter/authprovider.dart ;
//just call this... when user click on button...

var auth = AuthProvider.of(context).auth;
auth.handleSignIn();

And You Done...

希望会有所助益。





相关问题
Flutter App cannot be installed on Android TV

I m building a Flutter app that should support Android TV and Mobile devices. Despite Google Play shows that it is supported, I cannot install app on my MiBox device. While trying to install it, both ...

Moving the icon button to the right causes rendering issues

I am trying to align the icon button to the right of the Text field, I tried the row which made the icon button not centered vertically and now I am trying out the Stack widget. Here is my code - ...