【发布时间】:2021-04-04 16:54:58
【问题描述】:
我试图用手机登录。每次我输入手机号码时,它都会显示这些错误消息并退出应用程序。我使用了来自https://firebase.flutter.dev/docs/auth/phone 文档的代码。代码与文档几乎相同。
E/zzf (31149): Problem retrieving SafetyNet Token: 7:
I/Timeline(31149): Timeline: Activity_launch_request time:483815514
W/ActivityThread(31149): SCHED: com.example.newdevice/.MainActivity [85, r=578ms, a=96ms, w=57017ms]
W/ActivityThread(31149): handleWindowVisibility: no activity for token android.os.BinderProxy@dc5d811
D/ForceDarkHelper(31149): updateByCheckExcludeList: pkg: com.example.newdevice activity: com.google.firebase.auth.internal.RecaptchaActivity@5ed566f
I/chatty (31149): uid=10315(com.example.newdevice) identical 1 line
D/ForceDarkHelper(31149): updateByCheckExcludeList: pkg: com.example.newdevice activity: com.google.firebase.auth.internal.RecaptchaActivity@5ed566f
W/ample.newdevic(31149): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/ample.newdevic(31149): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/ample.newdevic(31149): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/ample.newdevic(31149): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/ample.newdevic(31149): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/ample.newdevic(31149): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/ample.newdevic(31149): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
......More error message.......
我正在为 Java/Flutter/Firebase sdk 等所有内容使用更新版本。我还在 Firebase 应用程序中添加了 SHA1 密钥并启用了电话身份验证。 我还尝试了物理设备和虚拟设备。但每次都是同样的问题。
应用级 build.gradel 文件中的依赖项
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:26.2.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.browser:browser:1.3.0'
implementation 'com.android.support:multidex:1.0.3'
}
用于移动验证的 Flutter 代码部分:
FirebaseAuth _auth = FirebaseAuth.instance;
await _auth.verifyPhoneNumber(
phoneNumber: mobileController.text,
verificationCompleted:
(PhoneAuthCredential credential) {
print(credential);
},
verificationFailed: (FirebaseAuthException error) {
print(error);
},
codeSent:
(String verificationId, int resendToken) async {
print('Your otp sent');
String smsCode = '123456';
PhoneAuthCredential phoneAuthCredential = PhoneAuthProvider.credential(verificationId: verificationId, smsCode: smsCode);
// Sign the user in (or link) with the credential
await _auth.signInWithCredential(phoneAuthCredential);
},
timeout: const Duration(seconds: 120),
codeAutoRetrievalTimeout: (String verificationId) {
print(verificationId);
}
);
我在这里糟透了。几乎尽我所能。
【问题讨论】:
-
请编辑问题以显示所有相关代码,即使它与其他代码“几乎相同”。请务必说明该代码无法按您预期的方式运行的原因。
-
感谢您的 cmets。现在添加了 Flutter 代码部分。 “codeSent”函数从未执行。
标签: android flutter dart firebase-authentication