Firebase phone authentication is not working on Android real device
Android has added SafetyNet you can read more here. But what you have to do is
1. enable the Android Device verification api here. and
2. If you haven't yet specified your app's SHA-256 fingerprint, do so from the Settings Page of the Firebase console. For more info read details here.
SafetyNet is newly developed feature for android. But solved the issue without doing any changes in the App.
Following steps helped me to solve.
Release Version
- Google Signs the Appbundle when you upload. So, Find and copy the SHA1 key of the app signed by google. Google Play Console - App Signing Key
- Navigate to your project -> Project Settings in Firebase Console and add SHA1 key by clicking on Add fingureprint.
Debug version
- Navigate to android directory of your project with following command with Terminal.
cd android
- Generate app signingReport and copy the SHA1 key
gradlew signingReport
on Mac :
./gradlew signingReport
- Add the SHA1 key in firebase app.
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.
I resolved my issue by removing by old android studio sha-1 and sha-256 keys from firebase and adding a new one from the latest android studio.