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.
Go to google cloud console , select your project .
Click on navigation menu and select APis & services and then select Dashboard .
Click on enable api and services and enable api " Android Device Verification".
Add SHA 256 in firebase project settings.(debug and release both)
Download and replace the latest google-services.json file in your project.
Related Topics
Android and Getting a View with Id Cast as a String
Polyline Is Not on the Roads: It Goes Straight from One Point to Other
Onintercepttouchevent Only Gets Action_Down
Deadobjectexception on Android App
Onrequestpermissionsresult Not Being Called in Dialog Fragment
Android Getintent().Getextras() Returns Null
How to Highlight Multiple Words in Edittext
R: Cannot Install Rjava; What Is R-Api-3.4
Java Equivalent to JavaScript's Encodeuricomponent That Produces Identical Output
How to Persist Permission in Android API 19 (Kitkat)
Android: Google Maps API - Change Position of Maps Toolbar
Httpurlconnection.Getresponsecode() Returns -1 on Second Invocation
How to Remove a Specific Element from a JSONarray
How to Create JSON Object Using String
On Zoom Event for Google Maps on Android
Android - Imageloader Must Be Init with Configuration Before Using in Uil
Android Studio Mailto Intent Doesn't Show Subject and Mail Body