简体   繁体   English

电话身份验证 google firebase 失败

[英]Phone authentication google firebase failed

I used google firebase phone authentication this is my code: https://codeshare.io/5MrgVy until yesterday it worked, today instead every time I enter a phone number the toast appears which should appear in this case:我使用了 google firebase 电话身份验证,这是我的代码: https : //codeshare.io/5MrgVy直到昨天它都有效,今天每次我输入电话号码时都会出现吐司,在这种情况下应该出现:

public void onVerificationFailed (FirebaseException e) {loadingBar.dismiss ();

                Toast.makeText (RegistrationActivity.this, "Invalid number entered ...", Toast.LENGTH_SHORT) .show ();
                relativeLayout.setVisibility (View.VISIBLE);


                continueAndNextBtn.setText ("Continue"); // Continue
                codeText.setVisibility (View.GONE);


            }

Lately I did a referactor to change the name of the project package, and after doing this it gave me this error: No matching client found for package name 'com.conta.ftof' I solved that error by replacing the old packages inside google-services.json with the new one.最近我做了一个引用器来更改项目包的名称,这样做后它给了我这个错误:没有找到包名称“com.conta.ftof”的匹配客户端我通过替换谷歌中的旧包解决了这个错误- services.json 与新的。 I told you this because I'm afraid this is the cause.我告诉你这个是因为我担心这就是原因。 How could I fix the authentication fact?我怎样才能解决认证事实?

edit:编辑:

I noticed this strange thing in the build output:我在构建输出中注意到了这个奇怪的事情:

activity#com.google.firebase.auth.internal.FederatedSignInActivity@android: launchMode was tagged at AndroidManifest.xml: 24 to replace other declarations but no other declaration present activity#com.google.firebase.auth.internal.FederatedSignInActivity@android: launchMode 在 AndroidManifest.xml: 24 被标记为替换其他声明但没有其他声明存在

logcat日志猫

2020-10-11 21:25:28.819 15302-15302/com.conta.ftof E/RegistrationActivity: err : com.google.firebase.auth.FirebaseAuthException: This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed ]

AndroidMAnifest: Android清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.conta.ftof">



    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".donate" />
        <activity android:name=".VideoCallActivity" />
        <activity android:name=".CallingActivity" />
        <activity android:name=".ProfileActivity" />
        <activity android:name=".FindPeopleActivity" />
        <activity android:name=".NotificationsActivity" />
        <activity android:name=".SettingsActivity" />
        <activity
            android:name=".ContactsActivity"
            android:label="@string/title_activity_main" />
        <activity android:name=".RegistrationActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />



                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-3400243939195187~6852949310"/>

        <receiver android:name=".ReminderBroadcast"/>
    </application>

</manifest>

there can be many reasons of the failure.失败的原因可能有很多。 you can try the folowing你可以试试下面的

try checking every case尝试检查每个案例

[EDIT]: FIREBASE PHONE AUTH ERROR HANDLING [编辑]:Firebase 电话授权错误处理

try the following code it ll help you a bit试试下面的代码,它会帮助你一点

@Override
public void onVerificationFailed(FirebaseException e) {
    if (e instanceof FirebaseAuthInvalidCredentialsException) {
        // Failed to verify due to wrong format mobile number
    } else if (e instanceof FirebaseTooManyRequestsException) {
        // Failed to verify due to usage over quota limit
    }
}

@Harkal @哈卡尔

Logcat after the click on the btn continue logcat后点击btn continue

2020-10-11 21:25:28.819 15302-15302/com.conta.ftof E/RegistrationActivity: err : com.google.firebase.auth.FirebaseAuthException: This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed ]

I solved.我解决了。 The cause was that I had changed the package name and therefore would have to change the package name in firebase as well.原因是我更改了包名称,因此也必须更改 firebase 中的包名称。 I created a new app on firebase and this time I put the right package name, replacing the google-services.json file with the old one ... Now it works!我在 firebase 上创建了一个新应用,这次我输入了正确的包名,用旧的替换了 google-services.json 文件......现在它可以工作了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM