我尝试使用fluttefire命令行工具为我的flutter项目添加firebase。我使用Google身份验证服务从firebase和调用SignIn
函数,它会给出以下错误。ios文件夹有GoogleService-Info.plist
文件。
Unhandled Exception: PlatformException(missing-config, GoogleService-Info.plist file not found and clientId was not provided programmatically., null, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
<asynchronous suspension>
#2 GoogleSignInPlatform.initWithParams (package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart:98:5)
<asynchronous suspension>
#3 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:267:5)
<asynchronous suspension>
#4 GoogleSignIn.signIn.isCanceled (package:google_sign_in/google_sign_in.dart:402:5)
发布于 2022-07-25 03:13:37
FlutterFire命令行工具生成Dart文件,因此不需要GoogleService-Info.plist
。尽管使用命令行工具插入GoogleService-Info.plist
是多余的。但是,在初始化时还必须指定生成的选项:
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)
使用DefaultFirebaseOptions
是使用Firebase的新方法,而手动插入配置文件则是旧的方法。
编辑:我不明白这个问题与GoogleSignIn
插件有关(我没有真正读过堆栈跟踪)。在这种情况下,错误与错误消息中的错误完全相同。您没有指定客户端id:
GoogleSignIn(clientId: DefaultFirebaseOptions.currentPlatform.iosClientId).signIn()
编辑:是的,新版本的flutterfire
也会生成相应的文件,如GoogleService-Info.plist
,但是您不再需要这些文件了,因为参数clientId
存在于GoogleSignIn
插件中。
发布于 2022-08-30 22:39:32
有人在github上发布了这个问题。https://github.com/flutter/flutter/issues/96248
他们说。
google_sign_in插件目前不支持只进行省道初始化,同时,您需要在手动安装上退步。
2022年8月31日,我仍然面临着同样的问题
发布于 2022-11-12 17:33:16
将GoogleService-Info.plist文件移动到Runner文件夹为我解决了这个问题。
https://stackoverflow.com/questions/73103392
复制相似问题