问题
Im new to flutter and im trying to implement firebase phone authentication in my app. Once i enter the mobile number ,after 2 to 3 seconds, app closes abruptly.
phoneAuth(number) async {
await authInstance.verifyPhoneNumber(
phoneNumber: "+91$number",
verificationCompleted: (PhoneAuthCredential credentials) async {
await authInstance
.signInWithCredential(credentials)
.then((UserCredential userCredentials) {
Get.to(HomeScreen());
});
},
verificationFailed: (FirebaseAuthException e) {
MyErrorPrinter.printError(
error: e, errorTitle: "verification failed");
},
codeSent: (String verificationId, int resendToken) async {
// Update the UI - wait for the user to enter the SMS code
String smsCode;
PhoneAuthCredential phoneAuthCredential;
TextEditingController textController = TextEditingController();
Get.dialog(
Container(
height: 300,
child: Column(
children: [
TextField(
controller: textController,
),
RaisedButton(
onPressed: () async {
phoneAuthCredential = PhoneAuthProvider.credential(
verificationId: verificationId, smsCode: smsCode);
await authInstance
.signInWithCredential(phoneAuthCredential)
.then((value) => print(
"[][][][][][] ------ fucking execute the route here"));
},
),
],
),
),
);
// Sign the user in (or link) with the credential
},
codeAutoRetrievalTimeout: (verficationId) {});
}
The following the the logs from my console, after i have pressed the button that executes phoneAuth()
W/IInputConnectionWrapper(19618): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper(19618): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(19618): getTextAfterCursor on inactive InputConnection
E/zzf (19618): Problem retrieving SafetyNet Token: 7:
I/Timeline(19618): Timeline: Activity_launch_request time:708035128
W/ActivityThread(19618): handleWindowVisibility: no activity for token android.os.BinderProxy@ad00795
D/ForceDarkHelper(19618): updateByCheckExcludeList: pkg: com.hstacks.vigorous activity: com.google.firebase.auth.internal.RecaptchaActivity@ea08e50
I/chatty (19618): uid=10314(com.hstacks.vigorous) identical 1 line
D/ForceDarkHelper(19618): updateByCheckExcludeList: pkg: com.hstacks.vigorous activity: com.google.firebase.auth.internal.RecaptchaActivity@ea08e50
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
I/chatty (19618): uid=10314(com.hstacks.vigorous) identical 1 line
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Llibcore/io/Memory;->peekLong(JZ)J (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Llibcore/io/Memory;->pokeLong(JJZ)V (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Llibcore/io/Memory;->pokeInt(JIZ)V (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Llibcore/io/Memory;->peekInt(JZ)I (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Llibcore/io/Memory;->pokeByte(JB)V (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Llibcore/io/Memory;->peekByte(J)B (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Llibcore/io/Memory;->pokeByteArray(J[BII)V (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Llibcore/io/Memory;->peekByteArray(J[BII)V (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->arrayIndexScale(Ljava/lang/Class;)I (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, reflection, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, reflection, allowed)
2
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
I/chatty (19618): uid=10314(com.hstacks.vigorous) identical 1 line
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
2
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
I/zzkn (19618): Provider GmsCore_OpenSSL not available
W/stacks.vigorou(19618): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
V/PhoneWindow(19618): DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@1b3435e[]
D/ViewRootImpl[RecaptchaActivity](19618): hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
V/PhoneWindow(19618): DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@521d155, this = DecorView@1b3435e[RecaptchaActivity]
W/System (19618): Ignoring header X-Firebase-Locale because its value was null.
I/System.out(19618): [okhttp]:check permission begin!
W/System (19618): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(19618): [okhttp] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
I/System.out(19618): [socket]:check permission begin!
W/System (19618): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(19618): [socket] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
E/GraphicExt(19618): GraphicExtModuleLoader::CreateGraphicExtInstance false
D/Surface (19618): Surface::connect(this=0x7ba794c000,api=1)
D/mali_winsys(19618): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/Surface (19618): Surface::setBufferCount(this=0x7ba794c000,bufferCount=3)
D/Surface (19618): Surface::allocateBuffers(this=0x7ba794c000)
I/System.out(19618): [OkHttp] sendRequest>>
I/System.out(19618): [OkHttp] sendRequest<<
D/AndroidRuntime(19618): Shutting down VM
E/AndroidRuntime(19618): FATAL EXCEPTION: main
E/AndroidRuntime(19618): Process: com.hstacks.vigorous, PID: 19618
E/AndroidRuntime(19618): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime(19618): at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.2:13)
E/AndroidRuntime(19618): at com.google.android.gms.internal.firebase-auth-api.zztw.zzb(com.google.firebase:firebase-auth@@20.0.2:7)
E/AndroidRuntime(19618): at com.google.android.gms.internal.firebase-auth-api.zztw.onPostExecute(Unknown Source:2)
E/AndroidRuntime(19618): at android.os.AsyncTask.finish(AsyncTask.java:755)
E/AndroidRuntime(19618): at android.os.AsyncTask.access$900(AsyncTask.java:192)
E/AndroidRuntime(19618): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
E/AndroidRuntime(19618): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(19618): at android.os.Looper.loop(Looper.java:224)
E/AndroidRuntime(19618): at android.app.ActivityThread.main(ActivityThread.java:7551)
E/AndroidRuntime(19618): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(19618): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/AndroidRuntime(19618): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
E/AndroidRuntime(19618): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.hstacks.vigorous-Squ6-rnc2y8vbv9T1Nrxew==/base.apk"],nativeLibraryDirectories=[/data/app/com.hstacks.vigorous-Squ6-rnc2y8vbv9T1Nrxew==/lib/arm64, /data/app/com.hstacks.vigorous-Squ6-rnc2y8vbv9T1Nrxew==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
E/AndroidRuntime(19618): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
E/AndroidRuntime(19618): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(19618): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(19618): ... 12 more
I/Process (19618): Sending signal. PID: 19618 SIG: 9
Lost connection to device.
Exited (sigterm)
NOTE :
vigorous
is the app name, hstacks
is the organisation name and hence the package name com.hstacks.vogorous
im stuck with for two days and still .Any help will be greatly appreciated !
回答1:
I faced the same issue for several days. Recently Firebase have updated certain things one of them is they have included captcha verification before sending the code or OTP.
To solve this issue :
add the following to project/android/app/build.gradle
implementation "androidx.browser:browser:1.3.0"
add this in the dependencies section ...
dependencies {
implementation "androidx.browser:browser:1.3.0"
///
}
you can find the latest version here: android browser .
REASON:
The app tries to verify the captcha and send the code, for that it tries to launch a browser but because of the missing implementation it fails to load a browser and crashes the application.
回答2:
This update, which @basudev nayak
mentioned about the firebase is not yet mentioned in https://firebase.flutter.dev/docs/auth/phone/
so, if anybody encounters such issues and of its kind in future, Please do check out https://firebase.google.com/docs/auth/android/phone-auth
Because the update procedures are atleast mentioned here !
happy dev!
来源:https://stackoverflow.com/questions/65897637/flutter-firebase-phone-authentication-problem-app-closes-abruptly