Reputation: 181
This question is not similar to any of the others. I've already tried many solutions from App crashes with firebase phone auth, error while getting firebase phone auth OTP
Android app crashes on firebase phone authentication, but nothing works.
In my flutter app(android) I am using firebase phone authentication. When I call the 'verifyPhoneNumber' method of firebase to send OTP, my app getting crashes and exits leaving no error message.
Here's my code
final FirebaseAuth _auth = FirebaseAuth.instance;
Future sendOTP(String mobNo, BuildContext context, UserData _userData) async {
try {
_auth.verifyPhoneNumber(
phoneNumber: mobNo,
verificationCompleted: (val) {
print("verification completed val = $val");
},
verificationFailed: (val) {
print("verification failed val = $val");
},
codeSent: (String verificationId, [int forceResendingToken]) {
print("code sent to $mobNo");
Navigator.pushNamed(context, '/get_otp', arguments: {
'verificationId': verificationId,
'UserData': _userData,
});
},
codeAutoRetrievalTimeout: (val) {
print("code auto retrieval timeout val = $val");
});
} catch (e) {
print("auth error = $e");
}
}
I added my SHA-1, SHA-256 certificates in my firebase project, I tried changing versions of firebase_auth, fiebase_core. But, nothing works. I tried adding breakpoints in all the lines. The app exits when the reaches this line.
_auth.verifyPhoneNumber(
It is not proceeding further.
Please help me to solve this!!ðŸ˜
Here's my debug console log
E/AndroidRuntime(17712): java.lang.NoClassDefFoundError: Failed resolution of:
Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime(17712): at
com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-
auth@@20.0.2:13)
E/AndroidRuntime(17712): at com.google.android.gms.internal.firebase-auth-
api.zztw.zzb(com.google.firebase:firebase-auth@@20.0.2:7)
E/AndroidRuntime(17712): at com.google.android.gms.internal.firebase-auth-
api.zztw.onPostExecute(Unknown Source:2)
E/AndroidRuntime(17712): at android.os.AsyncTask.finish(AsyncTask.java:755)
E/AndroidRuntime(17712): at android.os.AsyncTask.access$900(AsyncTask.java:192)
E/AndroidRuntime(17712): at
android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
E/AndroidRuntime(17712): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(17712): at android.os.Looper.loop(Looper.java:228)
E/AndroidRuntime(17712): at
android.app.ActivityThread.main(ActivityThread.java:7826)
E/AndroidRuntime(17712): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(17712): at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime(17712): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
E/AndroidRuntime(17712): Caused by: java.lang.ClassNotFoundException: Didn't find
class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip
file "/data/app/com.creda.location_project-
1fyv3Q9ek4vLZKMcRkGyDQ==/base.apk"],nativeLibraryDirectories=
[/data/app/com.creda.location_project-1fyv3Q9ek4vLZKMcRkGyDQ==/lib/arm64,
/data/app/com.creda.location_project-1fyv3Q9ek4vLZKMcRkGyDQ==/base.apk!/lib/arm64-v8a,
/system/lib64, /system/product/lib64]]
Upvotes: 1
Views: 3795
Reputation: 2319
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.
Upvotes: 7
Reputation: 6786
Refer this https://github.com/firebase/firebase-android-sdk/issues/2164
Adding "implementation 'androidx.browser:browser:1.3.0' " in app/build.gradle will solve this problem. This dependency is needed for firebase_auth > version 20.0 . Firebase didn't mention about this new modification in any of the release notes. Or may be its just a bug as the issue is still open.
Upvotes: 2
Reputation: 181
Yes, Adding "implementation 'androidx.browser:browser:1.3.0' " in my app/build.gradle solved this problem. This dependency is needed for firebase_auth > version 20.0 . Firebase didn't mention about this new modification in any of the release notes. Anyway Stack Overflow members did it. Thanks to all who helped me to solve this. 😇
Upvotes: 0