我一个试图添加一个登录与谷歌按钮,但它仍然现在工作,实际上它是不返回从线
await googleSignIn.signIn();
字符串
结果异常
E/扑动(12458):[错误:flutter/runtime/dart_vm_initializer.cc(41)]无法处理的异常:PlatformException(sign_in_failed,com.google.android.gms.common. apiException:10:,null,null)
这是我控制器代码
static Future<User> signInWithGoogle({@required BuildContext context}) async {
FirebaseAuth auth = FirebaseAuth.instance;
User user;
log("first of all ");
final GoogleSignIn googleSignIn = GoogleSignIn();
final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
log('++++++++++++++++++++++++++++ after await ');
if (googleSignInAccount != null) {
log('++++++++++++++++++++++++++++ nor null ');
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleSignInAuthentication.accessToken,
idToken: googleSignInAuthentication.idToken,
);
try {
final UserCredential userCredential =
await auth.signInWithCredential(credential);
user = userCredential.user;
} on FirebaseAuthException catch (e) {
if (e.code == 'account-exists-with-different-credential') {
//
} else if (e.code == 'invalid-credential') {
//
}
} catch (e) {
// ...
}
}
return user;
}
型
这里是按下动作的按钮:
OutlinedButton(
onPressed: () async {
setState(() {
_isSigningIn = true;
});
AuthController.signInWithGoogle(context: context);
setState(() {
_isSigningIn = false;
});
},
),
型
android/app/build.gradle文件:
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.google.firebase:firebase-messaging:21.0.1"
implementation 'com.facebook.android:facebook-android-sdk:latest.release'
implementation 'androidx.work:work-runtime-ktx:2.7.0'
}
型
android/build.gradle文件:
buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.13'
}
}
型
android/gradle.properties文件:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
型
我已经尝试了很多方法来调用firebase验证器,但所有的方法都以相同的错误和相同的结果结束,它仍然在等待返回相同的异常。提前感谢你的帮助
1条答案
按热度按时间ohtdti5x1#
我发现谷歌提供商没有启用raghav 042的评论,所以我启用了它,然后我添加了SHA-1指纹到firebase项目,并添加新的谷歌服务文件到我的Android应用程序,然后错误已经消失!!。非常感谢