I'm trying to implement the phone_auth provided by firebase, but it throws these errors and force closes when FirebaseAuth.instance.verifyPhoneNumber() is called.
E/zza (12829): Problem retrieving SafetyNet Token: 7:
W/ActivityThread(12829): handleWindowVisibility: no activity for token android.os.BinderProxy@28af8e3
W/mesecure.wmsap(12829): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/mesecure.wmsap(12829): Accessing hidden method Lsun/misc/Unsafe;-
>getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/mesecure.wmsap(12829): Accessing hidden method Lsun/misc/Unsafe;-
>putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/mesecure.wmsap(12829): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/mesecure.wmsap(12829): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/mesecure.wmsap(12829): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
.
.
D/DecorView(12829): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@5ad02b8[RecaptchaActivity]
D/AndroidRuntime(12829): Shutting down VM
E/AndroidRuntime(12829): FATAL EXCEPTION: main
E/AndroidRuntime(12829): Process: com.webmesecure.wmsapp, PID: 12829
E/AndroidRuntime(12829): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime(12829): at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:92)
E/AndroidRuntime(12829): at com.google.firebase.auth.api.internal.zzeq.zza(com.google.firebase:firebase-auth@@20.0.0:79)
E/AndroidRuntime(12829): at com.google.firebase.auth.api.internal.zzeq.onPostExecute(com.google.firebase:firebase-auth@@20.0.0:88)
E/AndroidRuntime(12829): at android.os.AsyncTask.finish(AsyncTask.java:755)
E/AndroidRuntime(12829): at android.os.AsyncTask.access$900(AsyncTask.java:192)
E/AndroidRuntime(12829): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
E/AndroidRuntime(12829): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(12829): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(12829): at android.app.ActivityThread.main(ActivityThread.java:7682)
E/AndroidRuntime(12829): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12829): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
E/AndroidRuntime(12829): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/AndroidRuntime(12829): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.webmesecure.wmsapp-q6bDzrSR-XHplgXhRtWLoQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.webmesecure.wmsapp-q6bDzrSR-XHplgXhRtWLoQ==/lib/arm64, /data/app/com.webmesecure.wmsapp-q6bDzrSR-XHplgXhRtWLoQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
E/AndroidRuntime(12829): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
E/AndroidRuntime(12829): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(12829): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(12829): ... 12 more
I/Process (12829): Sending signal. PID: 12829 SIG: 9
Lost connection to device.
This is my code, I'm calling the verifyPhoneNumber() when a button s pressed after getting the phone number from the user.
String phoneNumber, verificationId;
String otp, authStatus = "";
Future<void> verifyPhoneNumber(BuildContext context) async {
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: const Duration(seconds: 15),
verificationCompleted: (AuthCredential authCredential) {
setState(() {
authStatus = "Your account is successfully verified";
});
},
verificationFailed: (FirebaseAuthException authException) {
setState(() {
authStatus = "Authentication failed";
});
},
codeSent: (String verId, [int forceCodeResent]) {
verificationId = verId;
setState(() {
authStatus = "OTP has been successfully send";
});
otpDialogBox(context).then((value) {});
},
codeAutoRetrievalTimeout: (String verId) {
verificationId = verId;
setState(() {
authStatus = "TIMEOUT";
});
},
);
}
Future<void> verifyPhoneNumber(BuildContext context) async {
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: const Duration(seconds: 15),
verificationCompleted: (AuthCredential authCredential) {
setState(() {
authStatus = "Your account is successfully verified";
});
},
verificationFailed: (FirebaseAuthException authException) {
setState(() {
authStatus = "Authentication failed";
});
},
codeSent: (String verId, [int forceCodeResent]) {
verificationId = verId;
setState(() {
authStatus = "OTP has been successfully send";
});
otpDialogBox(context).then((value) {});
},
codeAutoRetrievalTimeout: (String verId) {
verificationId = verId;
setState(() {
authStatus = "TIMEOUT";
});
},
);
}
otpDialogBox(BuildContext context) {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return new AlertDialog(
title: Text('Enter your OTP'),
content: Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
decoration: InputDecoration(
border: new OutlineInputBorder(
borderRadius: const BorderRadius.all(
const Radius.circular(30),
),
),
),
onChanged: (value) {
otp = value;
},
),
),
contentPadding: EdgeInsets.all(10.0),
actions: <Widget>[
FlatButton(
onPressed: () {
Navigator.of(context).pop();
signIn(otp);
},
child: Text(
'Submit',
),
),
],
);
});
}
Future<void> signIn(String otp) async {
await FirebaseAuth.instance
.signInWithCredential(PhoneAuthProvider.credential(
verificationId: verificationId,
smsCode: otp,
));
}
This has been bugging me for almost 3 days now. Any help would be greatly appreciated.
Ensure you have enabled Android Device Check API and you have added your SHA256 to the Firebase Console.
I'm having the same issue.The mistake is your dependencies in app/build.gradle in my case I added some extra dependecies from google analytics and after I deleted that it worked
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With