flutter - Flutter google_sign_in package 登录问题,PlatformException
问题描述
当我尝试使用谷歌帐户登录时,我在终端中收到该错误:
PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
我的 pubspec.yaml 文件:
google_sign_in: ^4.5.6
我的代码:
import 'package:google_sign_in/google_sign_in.dart';
class androidLogInPage extends StatefulWidget {
@override
_androidLogInPageState createState() => _androidLogInPageState();
}
class _androidLogInPageState extends State<androidLogInPage> {
bool _isLoggedIn = false;
GoogleSignIn _googleSignIn = GoogleSignIn();
Future _logIn() async {
try {
await _googleSignIn.signIn();
setState(() {
_isLoggedIn = true;
});
} catch (err) {
print(err);
}
}
_logOut() {
_googleSignIn.signOut();
setState(() {
_isLoggedIn = false;
});
}
我已经有了 SHA-1 密钥,我该怎么办?我需要帮助。
解决方案
通常,当您添加使用原生 Android 或 iOS 代码的依赖项时,会出现平台异常。我认为您应该关闭应用程序并重新运行应用程序,它应该可以工作。这是因为它只重新加载 Flutter 代码而不是本机代码。
推荐阅读
- visual-studio - 意外的标识符 char[32]
- swift - 关闭应用程序后 Firebase FCM 未更新无效令牌 Swift
- sql - Sql 选择不适用于 WHERE CLAUSE
- mongodb - 如何在 AWS 中将 MongoDB 云设置为源端点
- javascript - 在跨多天的每周计划中检查可用性
- highcharts - 如何在 highcharts 包装气泡中增加系列数据标签
- javascript - JSON 到 CSV 转换 (JavaScript) : 如何正确格式化 CSV 转换
- python - 如何将旧的 python 代码从 m2crypto 迁移到密码学(摘要的 RSA 签名)
- ruby-on-rails - 如何在 solr 5.3.1 中对正则表达式进行同义词匹配?
- ruby-on-rails - Rails - 如果用约束包装,redirect_to 找不到路由