I am working on one of my flutter project and trying to add firebase phone authentication but I encountered with the error related to safetynet.Whereas i am able to use other authentication methods e.g. SignInWithEmailAndPassword. Whenever I am calling my phoneLogin function i am getting the error. I have already installed google play service on my emulator.

CODE

        Future phoneLogin(String phone) async {
        BuildContext context;
        try {
          await auth.verifyPhoneNumber(
              phoneNumber: '+91$phone',
              timeout: const Duration(seconds: 30),
              verificationCompleted: (PhoneAuthCredential credentials) async {
                await auth.signInWithCredential(credentials);
              },
              verificationFailed: (FirebaseAuthException exception) {},
              codeSent: (String verificationId, [int forcedResendingToken]) {
                // print('1')
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (BuildContext context) => OtpPage(phone: phone),
                  ),
                );
              },
              codeAutoRetrievalTimeout: (String abc) {});
          return null;
        } catch (e) {
          return null;
        }
      }

ERROR

    E/zzbf    ( 6483): SafetyNet Attestation fails basic integrity.
    I/zzkn    ( 6483): Provider GmsCore_OpenSSL not available
    W/System  ( 6483): Ignoring header X-Firebase-Locale because its value was null.
    D/AndroidRuntime( 6483): Shutting down VM
    E/AndroidRuntime( 6483): FATAL EXCEPTION: main
    E/AndroidRuntime( 6483): Process: com.oneobit.greenobit, PID: 6483
    E/AndroidRuntime( 6483): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
    E/AndroidRuntime( 6483):    at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:[email protected]@20.0.2:13)
    E/AndroidRuntime( 6483):    at com.google.android.gms.internal.firebase-auth-api.zztw.zzb(com.google.firebase:[email protected]@20.0.2:7)
    E/AndroidRuntime( 6483):    at com.google.android.gms.internal.firebase-auth-api.zztw.onPostExecute(Unknown Source:2)
    E/AndroidRuntime( 6483):    at android.os.AsyncTask.finish(AsyncTask.java:771)
    E/AndroidRuntime( 6483):    at android.os.AsyncTask.access$900(AsyncTask.java:199)
    E/AndroidRuntime( 6483):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
    E/AndroidRuntime( 6483):    at android.os.Handler.dispatchMessage(Handler.java:106)
    E/AndroidRuntime( 6483):    at android.os.Looper.loop(Looper.java:223)
    E/AndroidRuntime( 6483):    at android.app.ActivityThread.main(ActivityThread.java:7656)
    E/AndroidRuntime( 6483):    at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime( 6483):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    E/AndroidRuntime( 6483):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
    E/AndroidRuntime( 6483): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/lib/x86, /data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
    E/AndroidRuntime( 6483):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
    E/AndroidRuntime( 6483):    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    E/AndroidRuntime( 6483):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    E/AndroidRuntime( 6483):    ... 12 more
    I/Process ( 6483): Sending signal. PID: 6483 SIG: 9
    Lost connection to device.

I have already updated SHA256 key to my Firebase console.


Solution 1: basudev nayak

Firebase have updated certain things one of them is they have included captcha verification before sending the code or OTP to mobile devices.

To solve this issue see bellow:

add the following to project/android/app/build.gradle

implementation "androidx.browser:browser:1.3.0"

add this in the dependencies section ...

dependencies {

implementation "androidx.browser:browser:1.3.0"
///
}

you can find the latest version here: android browser .

REASON:

The app tries to verify the captcha and send the code, for that it tries to launch a browser but because of the missing implementation it fails to load a browser and crashes the application.