android - Firebase SMS 验证/身份验证在某些设备上不起作用

标签 android firebase firebase-authentication

我正在使用 Firebase 短信验证进行身份验证。该代码在大多数设备上运行良好,但它在 OPPO A37fw 上显示 'com.google.firebase.auth.FirebaseAuthException'

这是我的代码,它在包括其他 Oppo 设备在内的所有设备上都能正常工作。仅在 OPPO A37fw 上显示此错误。

 PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks
        = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
    @Override
    public void onVerificationCompleted(PhoneAuthCredential credential) {
        Log.d(TAG, "onVerificationCompleted:" + credential);
        MobileVerification.credential = credential;
        openOTPvalidation(ON_VERIFICATION);
    }

    @Override
    public void onVerificationFailed(FirebaseException e) {
        postException(context, TAG, e);
    }

    @Override
    public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken token) {
        super.onCodeSent(s, token);
        verificationCode    = s;
        forceResendingToken = token;
        openOTPvalidation(OTP_SEND);
    }
};

private void getOTP() {
    if (activity != null) {
        pDialog = SupportingMethods.showDialogLoading(activity);
        pDialog.show();
    }
    String mobile   = "+91" + mob;
    PhoneAuthProvider.getInstance().verifyPhoneNumber(
            mobile,        // Phone number to verify
            60,                 // Timeout duration
            TimeUnit.SECONDS,   // Unit of timeout
            activity,               // Activity (for callback binding)
            callbacks);        // OnVerificationStateChangedCallbacks
}

Logcat 显示:

   com.google.firebase.auth.FirebaseAuthException: This app is not authorized to use Firebase Authentication. Please verifythat the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed ] 
        at com.google.firebase.auth.api.internal.zzdr.zzb(Unknown Source) 
        at com.google.firebase.auth.api.internal.zzet.zza(Unknown Source) 
        at com.google.firebase.auth.api.internal.zzew.run(Unknown Source) 
        at android.os.Handler.handleCallback(Handler.java:739) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at android.os.Looper.loop(Looper.java:160) 
        at android.app.ActivityThread.main(ActivityThread.java:5541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759) 
        ************ DEVICE INFORMATION *********** 
        Brand: OPPO 
        Device: A37f 
        Model: A37fw 
        Id: LMY47V 
        Product: A37fw

最佳答案

如果您在 android 助手的帮助下连接了 firebase,则可能会出现这些问题。因此您需要从 firbase 控制台下载一个新的 google-services.json 文件副本并将其添加到您的项目文件夹中。这可能对您有所帮助。

关于android - Firebase SMS 验证/身份验证在某些设备上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55914310/

相关文章:

android - 布局中的算术运算 - Android Data Binding

ios - 你如何退出 Firebase? ( objective-C )

java - 如何在没有特定路径的情况下在子项下添加子项?

java - 确保 Android 应用程序在单个进程中运行

Android Firebase 电子邮件验证

javascript - 如何使用 firebase 身份验证在用户注册过程中保存额外信息

android - 在 Flutter 的 PageView 中动态创建或重新排序子小部件

android - 只允许特定的人从谷歌游戏商店下载应用程序

android - 如何访问 TableLayout 中的 View

firebase - Flutter Web 配置文件隐私