首页 > 解决方案 > Firebase 身份验证注册时出现电话号码错误

问题描述

我正在使用 Firebase 身份验证使用电话号码进行注册。但是没有发送任何短信。

我收到此错误

W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() 返回 Gms: com.google.firebase.auth.api.internal.zzak@d5a4a6d

我的毕业档案

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha01'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'
}

标签: androidfirebasefirebase-authentication

解决方案


我了解到您错过了在您的应用程序中设置 Firebase。

从这里跟踪整个过程

确保您的应用程序的模块(应用程序级)目录中有google-services.json文件。

您的根级(项目级)Gradle 文件 (build.gradle) 必须包含这些行。

buildscript {

  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository
  }

  dependencies {
    // ...

    // Add the following line:
    classpath 'com.google.gms:google-services:4.2.0'  // Google Services plugin
  }
}

allprojects {
  // ...

  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository
    // ...
  }
}

然后在你的模块(应用级)Gradle 文件(通常是 app/build.gradle)中,在文件底部添加一行。

apply plugin: 'com.android.application'

android {
  // ...
}

// Add the following line to the bottom of the file:
apply plugin: 'com.google.gms.google-services'  // Google Play services Gradle plugin

在您的模块(应用级)Gradle 文件(通常是 app/build.gradle)中,添加核心 Firebase SDK 的依赖项:

dependencies {
 // ...
 implementation 'com.google.firebase:firebase-core:17.0.0'

 // Getting a "Could not find" error? Make sure that you've added
 // Google's Maven repository to your root-level build.gradle file
}

推荐阅读