Flutter、Firebase Google 登录错误 - I/flutter ( 5171): PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10:

问题描述 投票:0回答:1

我在尝试开发的 flutter 应用程序上登录 Google 时遇到问题。我在调试控制台上不断收到相同的错误 -

I/flutter ( 5171): PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)

我已经在我的 firebase 控制台上更新了我的 SHA-1 和 SHA-2 密钥,这花了我很长时间才找到作为命令行命令

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
keytool -list -v -keystore path-to-your-release-key.keystore -alias your-key-alias -storepass your-keystore-password -keypass your-key-password

显示以下错误

keytool error: java.lang.Exception: Keystore file does not exist: ~/.android/debug.keystore
java.lang.Exception: Keystore file does not exist: ~/.android/debug.keystore
        at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:923)
        at java.base/sun.security.tools.keytool.Main.run(Main.java:423)
        at java.base/sun.security.tools.keytool.Main.main(Main.java:416)
keytool error: java.lang.Exception: Keystore file does not exist: path-to-your-release-key.keystore
java.lang.Exception: Keystore file does not exist: path-to-your-release-key.keystore
        at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:923)
        at java.base/sun.security.tools.keytool.Main.run(Main.java:423)
        at java.base/sun.security.tools.keytool.Main.main(Main.java:416)
PS C:\Users\marsd> 

我被困住了,不知道该怎么办,任何帮助将不胜感激

flutter firebase firebase-authentication google-signin sha
1个回答
0
投票

文档非常差,我在生成 jks 文件时也遇到了这个问题。不过我找到了解决方案。您需要将“路径”替换为设备中的实际路径。像这样的东西。

keytool -genkey -v -keystore C:\Users\WINDOWS\debug-key.jks 
-storetype JKS -keyalg RSA -keysize 2048 -validity 10000 
-alias androiddebugkey

C:\Users\WINDOWS\
代表文件夹的路径,而
debug-key
代表 jks 文件的名称。同时,
androiddebugkey
是别名的名称。对于别名,您可以随意命名。

正确设置命令后,命令行将要求您填写密码,然后输入私人信息,例如名字、地址等。您可以选择忽略后者,只需点击输入密钥。

生成 jks 文件后,请确保转到您在命令中指定的文件夹,然后复制它。将其粘贴到 Flutter 项目的

android/app
目录中。然后转到
android/app/build.gradle
,像这样更新
signingConfigs
buildTypes
部分。

signingConfigs {
    debug {
        keyAlias 'the alias you specified'
        keyPassword 'the key password you inserted'
        storeFile file('"name of the file".jks')
        storePassword 'the store password you inserted'
    }
}

buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
}

您需要根据您在命令行中插入的信息进行相应修改。请注意,这仅适用于调试模式。对于发布模式,您需要重复整个步骤,并将

debug {
替换为
release {

希望这对您有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.