凭据的对话框(谷歌表单)已成功打开,但在我填写凭据后,我得到这个错误。我是按照这里的指示做的。创建了一个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.

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


当前回答

为了让google_sign_in正常工作,您可能需要采取其他步骤:

连接GooglePlay与Firebase [(https://github.com/flutter/flutter/issues/27599)

如果您可以在调试期间运行谷歌登录,但不能在发布期间运行,则很有可能您没有将发布密钥的SHA1和SHA256添加到firebase。 要获得发布密钥的sha,使用keytool -list -v -keystore ~/key。JKS -alias键

您最终应该得到至少6个SHA凭据:2个来自调试键,2个来自谷歌播放链接,2个来自发布键。请注意,您不需要重新下载google服务。在firebase中添加发布SHA凭据后,生成的。

添加GooglePlay Proguard规则(https://github.com/flutter/flutter/issues/19102)

# Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }

# GooglePlay Services
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class com.google.common.** { *; }
-dontwarn com.google.common.**

其他回答

在android / app /构建。我把com.android.tools.build:gradle:3.1.3/com.google.gms:google-services:3.2.1更改为com.android.tools.build:gradle:3.2.1/com.google.gms:google-services:4.2.0。这招奏效了。

我刚才也遇到了同样的问题。如果您正在运行调试,并且没有在firebase中注册SHA指纹,则可能会发生这种情况。 我通过生成一个调试来解决这个问题。并在Firebase的应用程序中注册它。别忘了下载新的谷歌服务。Json。 还有这个。

编辑 如果您无法在发布模式下使用身份验证,请尝试以下操作:

-添加释放密钥的SHA证书指纹。

Keytool -exportcert -list -v \ -alias <your-key-name> -keystore <path-to-product -keystore> .使用实例

要了解更多详细信息,请参阅“获取发布证书”部分https://developers.google.com/android/guides/client-auth

如果您的身份验证仍然不工作,可能是因为您从Playstore下载了应用程序,并且启用了“谷歌播放功能的应用程序签名”。 在这种情况下,进入play store发布控制台然后进入发布管理下的应用签名。您将在这里找到要在Firebase控制台中注册的SHA证书指纹。

“颤振清洁”是在Firebase控制台注册SHA1后每个人都缺少的一块!

我遇到了这个问题,花了5个小时才解决。我记得我在某个地方读到过,API Exception 10意味着指纹有问题。因此,它必须是密钥库或firebase中的错误配置。最终,它是密钥库。我仍然不确定为什么这样做有效,但这就是我所做的,顺便说一下,我使用的是Windows 10:

1)。确保在文件android/build中。我有以下几点:

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

2)。我将这两行添加到文件android/gradle.properties中

android.useAndroidX=true
android.enableJetifier=true

3)。导航到c:\ users \ youruser \。并删除了以下内容:

debug.keystore
debug.keystore.lock

4)。以admin打开终端,并在此目录中生成调试密钥存储库。

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

获得指纹:

$ keytool -list -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android 

5)。firebase配置中增加了SHA1指纹

我这边就这样了。我希望它能帮助到一些人。

同样的问题。我查看了signingReport,版本SHA1和SHA256与其他版本不一样。我在firebase中添加了这些值,并重新下载了goggles -services.json。这就解决了问题。

另外,在建立apk之前运行颤振清理。