简体   繁体   English

Flutter Firebase 手机身份验证不适用于 Android

[英]Flutter Firebase phone auth not working on Android

I'm trying to use the firebase phone verification login, but it's not working.我正在尝试使用 firebase 手机验证登录,但它不起作用。 The code is not sent.代码未发送。 I've tried to use "keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android" to add sha-1 and sha-256 keys (I tried other methods as well), but still not worked.我尝试使用“keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android”添加 sha-1 和 sha-256 密钥(我也尝试了其他方法) ,但仍然没有工作。 I tried to enable android device verification API, but nothing is working.我尝试启用 android 设备验证 API,但没有任何效果。 I don't know what more I can do, I've tried everything.我不知道我还能做什么,我已经尝试了一切。

Here's the code:这是代码:

      Future<void> _login() async {
    final _firebaseAuth = FirebaseAuth.instance;
    print('trying to send code');
    _firebaseAuth.verifyPhoneNumber(
      phoneNumber: '<myphonenumberhere>',
      verificationCompleted: (phoneAuthCredential) {
        print('verification completed');
      },
      verificationFailed: (exception) {
        print('verification failed');
      },
      codeSent: (verId, forceResToken) {
        print('code sent');
      },
      codeAutoRetrievalTimeout: (verId) {
        print('auto retieval timeouted');
      },
    );
  }
    I/flutter ( 5839): trying to send code
E/zzbf    ( 5839): SafetyNet Attestation fails basic integrity.
I/Timeline( 5839): Timeline: Activity_launch_request time:94668823 intent:Intent { act=com.google.firebase.auth.internal.ACTION_SHOW_RECAPTCHA pkg=com.example.test_phone_auth cmp=com.example.test_phone_auth/com.google.firebase.auth.internal.RecaptchaActivity (has extras) }
W/ActivityThread( 5839): handleWindowVisibility: no activity for token android.os.BinderProxy@7547327
W/test_phone_aut( 5839): Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)
W/zzdk    ( 5839): keyset not found, will generate a new one
W/zzdk    ( 5839): java.io.FileNotFoundException: can't read keyset; the pref value GenericIdpKeyset does not exist
W/zzdk    ( 5839):  at com.google.android.gms.internal.firebase-auth-api.zzdo.zzc(com.google.firebase:firebase-auth@@20.0.1:10)
W/zzdk    ( 5839):  at com.google.android.gms.internal.firebase-auth-api.zzdo.zzb(com.google.firebase:firebase-auth@@20.0.1:1)
W/zzdk    ( 5839):  at com.google.android.gms.internal.firebase-auth-api.zzat.zzi(com.google.firebase:firebase-auth@@20.0.1:1)
W/zzdk    ( 5839):  at com.google.android.gms.internal.firebase-auth-api.zzdj.zzi(com.google.firebase:firebase-auth@@20.0.1:1)
W/zzdk    ( 5839):  at com.google.android.gms.internal.firebase-auth-api.zzdj.zzd(com.google.firebase:firebase-auth@@20.0.1:2)
W/zzdk    ( 5839):  at com.google.firebase.auth.internal.zzk.<init>(com.google.firebase:firebase-auth@@20.0.1:7)
W/zzdk    ( 5839):  at com.google.firebase.auth.internal.zzk.zza(com.google.firebase:firebase-auth@@20.0.1:3)
W/zzdk    ( 5839):  at com.google.firebase.auth.internal.RecaptchaActivity.zzd(com.google.firebase:firebase-auth@@20.0.1:9)
W/zzdk    ( 5839):  at com.google.android.gms.internal.firebase-auth-api.zzth.<init>(com.google.firebase:firebase-auth@@20.0.1:13)
W/zzdk    ( 5839):  at com.google.firebase.auth.internal.RecaptchaActivity.onResume(com.google.firebase:firebase-auth@@20.0.1:43)
W/zzdk    ( 5839):  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1413)
W/zzdk    ( 5839):  at android.app.Activity.performResume(Activity.java:7400)
W/zzdk    ( 5839):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3820)
W/zzdk    ( 5839):  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3860)
W/zzdk    ( 5839):  at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
W/zzdk    ( 5839):  at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
W/zzdk    ( 5839):  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
W/zzdk    ( 5839):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
W/zzdk    ( 5839):  at android.os.Handler.dispatchMessage(Handler.java:106)
W/zzdk    ( 5839):  at android.os.Looper.loop(Looper.java:201)
W/zzdk    ( 5839):  at android.app.ActivityThread.main(ActivityThread.java:6810)
W/zzdk    ( 5839):  at java.lang.reflect.Method.invoke(Native Method)
W/zzdk    ( 5839):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
W/zzdk    ( 5839):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
I/zzjy    ( 5839): Provider GmsCore_OpenSSL not available
W/Activity( 5839): Slow Operation: Activity com.example.test_phone_auth/com.google.firebase.auth.internal.RecaptchaActivity onResume took 219ms
I/DpmTcmClient( 5839): RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
W/System  ( 5839): Ignoring header X-Firebase-Locale because its value was null.

If you're testing it on an emulator, you need to include the dependency androidx.browser:browser to make it works.如果您在模拟器上对其进行测试,则需要包含依赖androidx.browser:browser才能使其正常工作。

The SHA256 key and android device verification API is for a real device to pass Safetynet check. SHA256 密钥和 android 设备验证 API 用于真实设备通过 Safetynet 检查。

Check out the Enable app verification section and my response in the Flutterfire issue thread .查看启用应用验证部分和我在 Flutterfire 问题线程中的回复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM