我使用了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);
}
最近,我做了一个引荐人来更改项目包的名称,执行此操作后,它给了我这个错误:找不到与包名称'com.conta.ftof'相匹配的客户端。 我通过用新软件包替换google-services.json中的旧软件包解决了该错误。我告诉你这是因为我担心这是原因。我该如何解决身份验证问题?
编辑:
我在生成输出中注意到了这个奇怪的事情:
activity#com.google.firebase.auth.internal.FederatedSignInActivity@android:在AndroidManifest.xml:24中标记了launchMode以替换其他声明,但没有其他声明
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:
<?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>
答案 0 :(得分:0)
失败的原因可能有很多。您可以尝试以下
尝试检查每种情况
[EDIT]:FIREBASE电话授权错误处理
尝试以下代码,它将对您有所帮助
@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
}
}
答案 1 :(得分:0)
@Harkal
点击btn后的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 ]
答案 2 :(得分:0)
我解决了。原因是我更改了程序包名称,因此也必须在firebase中更改程序包名称。我在firebase上创建了一个新应用,这次我输入了正确的包名称,用旧的替换了google-services.json文件...现在可以使用了!