Flutter和google_sign_in插件: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null),无法签入。
Flutter和google_sign_in插件: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null),无法签入。
凭据对话框 (Google表单) 成功打开,但填写凭据后我收到了这个错误。 我遵循了这里的说明。 创建了一个Firebase项目,在Google API控制台中启用了Google Drive 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): E/flutter ( 5068): #2 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:226:58) E/flutter ( 5068): 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. (package:my_app/widgets/my_file.dart:666:45) E/flutter ( 5068): E/flutter ( 5068): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14) E/flutter ( 5068): #7 _InkResponseState.build. (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。
flutter 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.
任何帮助都将不胜感激。 谢谢!
我花费了很长时间来尝试修复这个问题。
1. 打开grade.properties,该文件位于:{{YOUR PROJECT}}/android/gradle.properties
2. 将以下参数添加到“org.gradle.jvmargs”中,如截图所示。
-XX:MaxHeapSize = 256m -Xmx256m
3. 右键单击“gradlew”,然后转到“在终端中打开”,该文件位于{{YOUR PROJECT}}/android/gradlew
4. 输入以下命令。
gradlew signingReport
如果第一次运行失败,请尝试第二个命令:
./gradlew signingReport
5. 等待编译完成,您的SHA密钥应该会被打印出来。
使用这些密钥在https://console.firebase.google.com/中认证您的应用程序。
我刚遇到了同样的问题。 如果您正在调试时并且未在 Firebase 中注册 SHA
指纹,可能会发生这种情况。 我通过运行以下命令生成 debug.keystore
解决了此问题:keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
然后在 Firebase 中注册它。之后不要忘记下载新的 google-services.json
文件。
请参考 此链接。
编辑
如果您无法在发布模式中进行认证,请尝试以下操作:
- 添加发布密钥的 SHA 证书指纹。
keytool -exportcert -list -v \ -alias
有关此的更多详细信息,请参见此处的 "获取发布证书" 部分。
如果您的身份验证仍然无法正常工作,则可能是因为您从 Playstore 下载应用并启用了 "由 Google Play 功能签名的应用程序签名"。 针对此情况,请转到发布控制台的应用程序签名下,在其中找到要在 Firebase 控制台中注册的 SHA 证书指纹。
这段内容展示了一个网页上的图片。