'Firebase Phone Authentication in flutter

I followed the flutter fire documentation for implementing the firebase phone auth. I tried this with the previous version of firebase_auth (firebase_auth:0.14.0+5) and everything seemed to work but I started a new app and installed the latest version of firebase_auth (firebase_auth:0.18.1+2) and anytime I call the firebase verifyNumber method my app carashes with this log :

E/zza     (12630): Problem retrieving SafetyNet Token: 7: 
D/ViewRootImpl@bab4cc4[MainActivity](12630): MSG_WINDOW_FOCUS_CHANGED 0
W/zzdq    (12630): keyset not found, will generate a new one
W/zzdq    (12630): java.io.FileNotFoundException: can't read keyset; the pref value GenericIdpKeyset does not exist
W/zzdq    (12630):  at com.google.android.gms.internal.firebase-auth-api.zzdv.zzc(com.google.firebase:firebase-auth@@20.0.0:13)
W/zzdq    (12630):  at com.google.android.gms.internal.firebase-auth-api.zzdv.zzb(com.google.firebase:firebase-auth@@20.0.0:32)
W/zzdq    (12630):  at com.google.android.gms.internal.firebase-auth-api.zzbd.zza(com.google.firebase:firebase-auth@@20.0.0:8)
W/zzdq    (12630):  at com.google.android.gms.internal.firebase-auth-api.zzdq$zza.zzd(com.google.firebase:firebase-auth@@20.0.0:73)
W/zzdq    (12630):  at com.google.android.gms.internal.firebase-auth-api.zzdq$zza.zzc(com.google.firebase:firebase-auth@@20.0.0:60)
W/zzdq    (12630):  at com.google.android.gms.internal.firebase-auth-api.zzdq$zza.zza(com.google.firebase:firebase-auth@@20.0.0:27)
W/zzdq    (12630):  at com.google.firebase.auth.internal.zzi.<init>(com.google.firebase:firebase-auth@@20.0.0:9)
W/zzdq    (12630):  at com.google.firebase.auth.internal.zzi.zza(com.google.firebase:firebase-auth@@20.0.0:17)
W/zzdq    (12630):  at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:116)
W/zzdq    (12630):  at com.google.firebase.auth.api.internal.zzeq.<init>(com.google.firebase:firebase-auth@@20.0.0:14)
W/zzdq    (12630):  at com.google.firebase.auth.internal.RecaptchaActivity.onResume(com.google.firebase:firebase-auth@@20.0.0:78)
W/zzdq    (12630):  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1277)
W/zzdq    (12630):  at android.app.Activity.performResume(Activity.java:7088)
W/zzdq    (12630):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3768)
W/zzdq    (12630):  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3832)
W/zzdq    (12630):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2994)
W/zzdq    (12630):  at android.app.ActivityThread.-wrap14(ActivityThread.java)
W/zzdq    (12630):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
W/zzdq    (12630):  at android.os.Handler.dispatchMessage(Handler.java:102)
W/zzdq    (12630):  at android.os.Looper.loop(Looper.java:154)
W/zzdq    (12630):  at android.app.ActivityThread.main(ActivityThread.java:6682)
W/zzdq    (12630):  at java.lang.reflect.Method.invoke(Native Method)
W/zzdq    (12630):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
W/zzdq    (12630):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
I/zzip    (12630): Provider GmsCore_OpenSSL not available
I/System.out(12630): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out(12630): (HTTPLog)-Static: isSBSettingEnabled false
D/ViewRootImpl@9c9340d[RecaptchaActivity](12630): ThreadedRenderer.create() translucent=true
D/InputTransport(12630): Input channel constructed: fd=95
D/ViewRootImpl@9c9340d[RecaptchaActivity](12630): setView = DecorView@7954fc2[RecaptchaActivity] touchMode=true
D/ViewRootImpl@9c9340d[RecaptchaActivity](12630): dispatchAttachedToWindow
D/ViewRootImpl@9c9340d[RecaptchaActivity](12630): Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1440,2560] result=0x27 surface={isValid=true 501132826624} surfaceGenerationChanged=true
D/ViewRootImpl@9c9340d[RecaptchaActivity](12630): mHardwareRenderer.initialize() mSurface={isValid=true 501132826624} hwInitialized=true
D/mali_winsys(12630): EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [1440x2560]-format:1
D/ViewRootImpl@9c9340d[RecaptchaActivity](12630): MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
D/ViewRootImpl@9c9340d[RecaptchaActivity](12630): MSG_WINDOW_FOCUS_CHANGED 1
D/ViewRootImpl@9c9340d[RecaptchaActivity](12630): mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 501132826624}
V/InputMethodManager(12630): Starting input: tba=android.view.inputmethod.EditorInfo@46ca60e nm : com.example.harpy ic=null
I/InputMethodManager(12630): [IMM] startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport(12630): Input channel constructed: fd=101
D/InputTransport(12630): Input channel destroyed: fd=93
W/IInputConnectionWrapper(12630): finishComposingText on inactive InputConnection
D/AndroidRuntime(12630): Shutting down VM
E/AndroidRuntime(12630): FATAL EXCEPTION: main
E/AndroidRuntime(12630): Process: com.example.harpy, PID: 12630
E/AndroidRuntime(12630): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime(12630):    at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:92)
E/AndroidRuntime(12630):    at com.google.firebase.auth.api.internal.zzeq.zza(com.google.firebase:firebase-auth@@20.0.0:79)
E/AndroidRuntime(12630):    at com.google.firebase.auth.api.internal.zzeq.onPostExecute(com.google.firebase:firebase-auth@@20.0.0:88)
E/AndroidRuntime(12630):    at android.os.AsyncTask.finish(AsyncTask.java:660)
E/AndroidRuntime(12630):    at android.os.AsyncTask.-wrap1(AsyncTask.java)
E/AndroidRuntime(12630):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
E/AndroidRuntime(12630):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(12630):    at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(12630):    at android.app.ActivityThread.main(ActivityThread.java:6682)
E/AndroidRuntime(12630):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12630):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
E/AndroidRuntime(12630):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
E/AndroidRuntime(12630): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.example.harpy-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.harpy-1/lib/arm64, /data/app/com.example.harpy-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
E/AndroidRuntime(12630):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(12630):    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
E/AndroidRuntime(12630):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(12630):    ... 12 more
Lost connection to device.

What could possibly be the reason my app is crashing?

NOTE: I do not recieve the SMS



Solution 1:[1]

I got the same problem and solved it by updating latest packaged of flutter and android and I add SHA-1 and SHA-256 and used only flutter documentation methods then It starts working fine

Solution 2:[2]

In my case, it was SHA-1 and SHA-256

Go to the project folder in the terminal.

Mac keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Windows keytool -list -v -keystore "\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

Linux keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Add SHA-1 and SHA-256 to your firebase Project*

Solution 3:[3]

Bro i faced the same issue and the only answer i could find by myself is that just use the earlier version in my case is used firebase_auth 19.3.2 the latest ones have some sorta bug. So just use the earlier one till time being.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Azhar Ali
Solution 2 Adie RT
Solution 3 DarkStrok