Caused By: Java.Lang.Classnotfoundexception: Didn't Find Class in Firebase Phone Authentication

Firebase phone authentication is not working on Android real device

I am guessing you have not enabled the Device Check API. All you need to do is enable the Device Check API on the cloud platform.

I think after some updates they have made this change that for Safety Net you need SH1 Authentication along with enabling Device Check API.

You can follow the Steps as mentioned here.

Once you enable the device check api. Restart your application. It should work like a charm.

Do lemme know if you need further steps.

How to fix Caused by: java.lang.ClassNotFoundException: Didn't find class androidx.browser.customtabs.CustomTabsIntent$Builder

I was facing same issue, please try following-

//import broswer(require for firebase reCaptch Verifications)
implementation 'androidx.browser:browser:1.2.0'

// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'

Make sure you put apply plugin: 'com.google.gms.google-services' // Google Services plugin
at top of build.gradle(app), and add a dependency in build.gradle(Project) as following-

buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'

classpath 'com.google.gms:google-services:4.3.4' // Google Services plugin

}

}

In case you are facing error as 'Static interface methods are only supported starting with Android N' then update Java Version to 1.8 via adding those lines
in your build.gradle(Project)

android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}

Happy coding!

Firebase Phone Verification verifyPhoneNumber() deprecated + Application Crashed

This is what I did to remove the Error:

I referred firebase phone auth documentation and made the necessary changes:

Replace this:

PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, //phone number to be verified
60, // validity of the OTP
TimeUnit.SECONDS,
(Activity) TaskExecutors.MAIN_THREAD,
mCallBack // onVerificationStateChangedCallback
);

With this

PhoneAuthOptions options =
PhoneAuthOptions.newBuilder(mAuth)
.setPhoneNumber(phoneNumber) // Phone number to verify
.setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
.setActivity(this) // Activity (for callback binding)
.setCallbacks(mCallBack) // OnVerificationStateChangedCallbacks
.build();
PhoneAuthProvider.verifyPhoneNumber(options);

Also, add this to your app/gradle file dependencies:

implementation 'androidx.browser:browser:1.2.0'

This will help firebase to open the browser for reCAPTCHA verification.

Hope this works!

Firebase Phone Auth is not working version 20.0.0 in android

Malcolm from Firebase here!

It looks like you're missing a set of OnVerificationStateChangedCallbacks - please call #setCallbacks() on your Builder.

I'll see if we can't get that error message to be less cryptic

Caused by: java.lang.ClassNotFoundException: Didn't find class com.google.firebase.FirebaseApp$IdTokenListenersCountChangedListener

I got the same problem as you. In the firebase release notes May 07, 2019 it says; "If you use Firebase Authentication, update to firebase-auth v17.0.0 or later to ensure functionality alignment with other updated Firebase libraries." So, I changed my firebase auth dependency to the latest version, which means;

com.google.firebase:firebase-auth:17.0.0

and it fixed up my problem. I hope it helps. Best of luck! :)

Also you can check the release notes from here

app crash while using firebase phone Auth in android

In new Firebase auth version i,e 20.0.0 ,they've made major changes like Recaptcha , SafetyNet for human verification. To fix crash you can add

implementation "androidx.browser:browser:1.3.0"

This dependency only fix crash but still user experience will not look good because firebase will open browser to verify Recaptcha .

Firebase Quote "The reCAPTCHA flow will only be triggered when SafetyNet is unavailable or your device does not pass suspicion checks. Nonetheless, you should ensure that both scenarios are working correctly." So to enable SafetyNet follow below steps or you can also visit Firebase Auth for more info.

  1. Go to google cloud console , select your project .

  2. Click on navigation menu and select APis & services and then select Dashboard .

  3. Click on enable api and services and enable api " Android Device Verification".

  4. Add SHA 256 in firebase project settings.(debug and release both)

  5. Download and replace the latest google-services.json file in your project.



Related Topics



Leave a reply



Submit