Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

Flutter Firebase phone auth not working on Android

I'm trying to use the firebase phone verification login, but it's not working. 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. I tried to enable android device verification API, but nothing is working. 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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you're testing it on an emulator, you need to include the dependency androidx.browser:browser to make it works.

The SHA256 key and android device verification API is for a real device to pass Safetynet check.

Check out the Enable app verification section and my response in the Flutterfire issue thread.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...