我正在研究我的一个扑动项目,并试图添加firebase电话身份验证,但我遇到了与安全网相关的错误。而我能够使用其他身份验证方法,例如SignInWithEmailAndPassword。每当我调用我的phonellogin函数,我得到的错误。我已经在模拟器上安装了google play服务。
Future phoneLogin(String phone) async {
BuildContext context;
try {
await auth.verifyPhoneNumber(
phoneNumber: '+91$phone',
timeout: const Duration(seconds: 30),
verificationCompleted: (PhoneAuthCredential credentials) async {
await auth.signInWithCredential(credentials);
},
verificationFailed: (FirebaseAuthException exception) {},
codeSent: (String verificationId, [int forcedResendingToken]) {
// print('1')
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => OtpPage(phone: phone),
),
);
},
codeAutoRetrievalTimeout: (String abc) {});
return null;
} catch (e) {
return null;
}
}
错误E/zzbf ( 6483): SafetyNet Attestation fails basic integrity.
I/zzkn ( 6483): Provider GmsCore_OpenSSL not available
W/System ( 6483): Ignoring header X-Firebase-Locale because its value was null.
D/AndroidRuntime( 6483): Shutting down VM
E/AndroidRuntime( 6483): FATAL EXCEPTION: main
E/AndroidRuntime( 6483): Process: com.oneobit.greenobit, PID: 6483
E/AndroidRuntime( 6483): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime( 6483): at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.2:13)
E/AndroidRuntime( 6483): at com.google.android.gms.internal.firebase-auth-api.zztw.zzb(com.google.firebase:firebase-auth@@20.0.2:7)
E/AndroidRuntime( 6483): at com.google.android.gms.internal.firebase-auth-api.zztw.onPostExecute(Unknown Source:2)
E/AndroidRuntime( 6483): at android.os.AsyncTask.finish(AsyncTask.java:771)
E/AndroidRuntime( 6483): at android.os.AsyncTask.access$900(AsyncTask.java:199)
E/AndroidRuntime( 6483): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
E/AndroidRuntime( 6483): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 6483): at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 6483): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 6483): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 6483): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 6483): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/AndroidRuntime( 6483): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/lib/x86, /data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
E/AndroidRuntime( 6483): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
E/AndroidRuntime( 6483): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime( 6483): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime( 6483): ... 12 more
I/Process ( 6483): Sending signal. PID: 6483 SIG: 9
Lost connection to device.
Future phoneLogin(String phone) async {
BuildContext context;
try {
await auth.verifyPhoneNumber(
phoneNumber: '+91$phone',
timeout: const Duration(seconds: 30),
verificationCompleted: (PhoneAuthCredential credentials) async {
await auth.signInWithCredential(credentials);
},
verificationFailed: (FirebaseAuthException exception) {},
codeSent: (String verificationId, [int forcedResendingToken]) {
// print('1')
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => OtpPage(phone: phone),
),
);
},
codeAutoRetrievalTimeout: (String abc) {});
return null;
} catch (e) {
return null;
}
}
E/zzbf ( 6483): SafetyNet Attestation fails basic integrity.
I/zzkn ( 6483): Provider GmsCore_OpenSSL not available
W/System ( 6483): Ignoring header X-Firebase-Locale because its value was null.
D/AndroidRuntime( 6483): Shutting down VM
E/AndroidRuntime( 6483): FATAL EXCEPTION: main
E/AndroidRuntime( 6483): Process: com.oneobit.greenobit, PID: 6483
E/AndroidRuntime( 6483): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime( 6483): at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.2:13)
E/AndroidRuntime( 6483): at com.google.android.gms.internal.firebase-auth-api.zztw.zzb(com.google.firebase:firebase-auth@@20.0.2:7)
E/AndroidRuntime( 6483): at com.google.android.gms.internal.firebase-auth-api.zztw.onPostExecute(Unknown Source:2)
E/AndroidRuntime( 6483): at android.os.AsyncTask.finish(AsyncTask.java:771)
E/AndroidRuntime( 6483): at android.os.AsyncTask.access$900(AsyncTask.java:199)
E/AndroidRuntime( 6483): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
E/AndroidRuntime( 6483): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 6483): at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 6483): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 6483): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 6483): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 6483): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/AndroidRuntime( 6483): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/lib/x86, /data/app/~~VMK8TkW9ozBJD9t7dnRn8g==/com.oneobit.greenobit-EtKxl5CBj6rDZiliq4I1ZQ==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
E/AndroidRuntime( 6483): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
E/AndroidRuntime( 6483): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime( 6483): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime( 6483): ... 12 more
I/Process ( 6483): Sending signal. PID: 6483 SIG: 9
Lost connection to device.
我已经更新了SHA256密钥到我的Firebase控制台。
Firebase已经更新了某些东西,其中之一是他们在发送代码或OTP到移动设备之前包含了captcha验证.
解决方法如下:
将以下内容添加到project/android/app/build.gradle
implementation "androidx.browser:browser:1.3.0"
把这个添加到依赖项部分…
dependencies {
implementation "androidx.browser:browser:1.3.0"
///
}
你可以在这里找到最新的版本:android浏览器。
原因:
应用程序尝试验证captcha并发送代码,因此它尝试启动浏览器,但由于缺少实现,它无法加载浏览器并导致应用程序崩溃。