凭据的对话框(谷歌表单)已成功打开,但在我填写凭据后,我得到这个错误。我是按照这里的指示做的。创建了一个Firebase项目,启用谷歌驱动器API(这是我现在需要的)从谷歌API控制台。

抛出异常的代码:

final GoogleSignIn _googleSignIn = GoogleSignIn(
  scopes: [
    'https://www.googleapis.com/auth/drive',
  ],
);

await _googleSignIn.signIn();

这是堆栈跟踪:

E/flutter ( 5068): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter ( 5068): PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
E/flutter ( 5068): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter ( 5068): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18)
E/flutter ( 5068): <asynchronous suspension>
E/flutter ( 5068): #2      GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:226:58)
E/flutter ( 5068): <asynchronous suspension>
E/flutter ( 5068): #3      GoogleSignIn._addMethodCall (package:google_sign_in/google_sign_in.dart:268:20)
E/flutter ( 5068): #4      GoogleSignIn.signIn (package:google_sign_in/google_sign_in.dart:339:48)
E/flutter ( 5068): #5      ThatsMyComponentState.theSignInFuction.<anonymous closure> (package:my_app/widgets/my_file.dart:666:45)
E/flutter ( 5068): <asynchronous suspension>
E/flutter ( 5068): #6      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter ( 5068): #7      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter ( 5068): #8      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter ( 5068): #9      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter ( 5068): #10     TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
E/flutter ( 5068): #11     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter ( 5068): #12     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
E/flutter ( 5068): #13     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter ( 5068): #14     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter ( 5068): #15     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter ( 5068): #16     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter ( 5068): #17     _invoke1 (dart:ui/hooks.dart:168:13)
E/flutter ( 5068): #18     _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)

google_sign_in插件版本为4.0.0。

这是颤振doctot -v的输出:

[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17763.253], locale en-US)
• Flutter version 1.0.0 at C:\src\flutter-0.7.3\flutter
• Framework revision 5391447fae (10 weeks ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at C:\Users\myuser\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = C:\Users\myuser\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.

[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 32.0.1
• Dart plugin version 182.5124
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] IntelliJ IDEA Community Edition (version 2018.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.6
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
  https://flutter.io/intellij-setup/#installing-the-plugins

[!] VS Code, 64-bit edition (version 1.30.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension not installed; install from
  https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)

! Doctor found issues in 2 categories.

任何帮助都将不胜感激。谢谢!


当前回答

在我的情况下,这是一个愚蠢的错误,确保你的applicationId在firebase像:com.example。appname与app/src/build中的applicationId完全匹配。gradle文件,在defaultConfig{}下。没有拼写错误,没有大写或小写字母冲突。在我的例子中,一个字母是大写的,这导致了所有的问题。

其他回答

您需要将SHA-1和SHA-256添加到Firebase项目。如果你已经使用Play app Signing发布了你的应用,这是使用Android app Bundle时的一个要求,你可以从谷歌Play控制台的发布> Setup > app Integrity页面上获得SHA-1。

您可能遇到此错误的一个原因是您没有填写谷歌的OAuth同意书。这是Firebase的一个新变化。

以下是你填写应用同意书时需要遵循的步骤:

Navigate to the google api console (currently at https://console.developers.google.com), make sure you are logged into your account which your firebase project is created under. Select your project from the "select a project" dropdown in top left of the developer console. In the left hand pane travel to "credentials" and then switch to the "OAuth consent screen". Under "Application name" enter your application's public name Under "Application logo" upload a local image file of your application Under "Support email" enter the same support email listed in your firebase application.

向下滚动并填写“应用程序主页链接”、“应用程序隐私政策链接”和“应用程序服务条款链接”,在您的firebase应用程序所在的授权域名前添加http://。

点击保存

这些步骤对我很有效!虽然链接可能不存在,但我想在这里引用这个解决方案的源代码

构建appbundle(谷歌Play and Flutter推荐使用)会导致此错误。构建apk将解决这个问题。

参见58194425

当在Firebase中注册应用程序时,我将我的applicationId更改为适合我的应用程序的内容。然而,这导致当我运行调试器时,我的手机上安装了第二个Flutter应用程序(当然,由于applicationId的变化)。所以,对我的情况起作用的事情,是删除安装和重新安装应用程序。

在我的例子中,问题在于当我在项目中添加口味时,我为每种口味设置了不同的应用程序id。但在Firebase控制台,我只有一个。请再核对一下申请证件。