vir*_*rus 17 firebase firebase-authentication flutter
当我尝试进行电话身份验证时,出现以下错误。
W/BiChannelGoogleApi(12340): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@489
Run Code Online (Sandbox Code Playgroud)
我在 Stackverflow 和其他地方检查了同样的错误,但没有在任何地方得到正确的解决方案。
pubspec.yml 中的更改
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
firebase_core: ^0.3.0+2 //new
firebase_auth: ^0.8.1+1 //new
Run Code Online (Sandbox Code Playgroud)
注意——添加了 //New 以突出我在上面文件中添加的行。
在app/build.gradle末尾添加以下行
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
android/build.gradle
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
android/app/build.gradle
.....
android {
compileSdkVersion 28
.....
defaultConfig {
....
minSdkVersion 21
targetSdkVersion 27
......
}
.....
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.1.0'
// implementation 'androidx.core:core-ktx:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
android/app/gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
我正在使用 AndroidX。
小智 13
我最近解决了这个问题。基本上这个错误有很多原因,因为当 FirebaseAuth 入口点执行失败时会返回这个错误。我遇到的这个错误的原因之一是我的模拟器没有连接到互联网 所以也在模拟器内部打开互联网。
我在这个问题上浪费了几个小时,所以让我分享一下我的经验。
Gms 代表“谷歌移动服务”,它基本上是谷歌开发的 Android 插件 API,允许连接到一堆谷歌提供的服务。如果您使用 flutter,这可能被您使用的 flutter 包包裹,例如 firebase_auth、flutter_facebook_login 或/和 google_sign_in。
此错误有时可能由更高级别的组件处理,因此如果您遇到该错误,并不意味着您的配置错误或无法运行。在我的情况下,当我使用 Google Sign in 登录时,我遇到了这个错误,最终结果是成功的,如下所示:
info flutter.tools W/BiChannelGoogleApi( 4106): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak@8116b2c
info flutter.tools D/FirebaseAuth( 4506): Notifying id token listeners about user ( lCZZZZJELWhGUZZZZB3vDklZZZZ2 ).
info flutter.tools D/FirebaseAuth( 4506): Notifying auth state listeners about user ( lCZZZZJELWhGUZZZZB3vDklZZZZ2 ).
info flutter.tools I/flutter ( 4506): FirebaseUser({uid: lCZZZZJELWhGUZZZZB3vDklZZZZ2, photoUrl: https://lh5.googleusercontent.com/-ZZzir_P-ENw/AAAAAAAAAAI/AAAAAAAAAAA/PpxhiXg_ISk/s96-c/photo.jpg, isAnonymous: false, etc....
Run Code Online (Sandbox Code Playgroud)
print(fireUser);
我的代码中有一个 dart 调用,所以我们看到它是成功的。
但是在 Facebook Auth 的情况下,我只是有这个,之后什么也没发生,但在 Facebook 服务器端,登录成功,因为我可以在 Facebook 开发控制台中看到事件。
info flutter.tools W/BiChannelGoogleApi( 4106): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak@8116b2c
Run Code Online (Sandbox Code Playgroud)
日志中没有其他内容,所以在这个过程中有些东西被卡住了。
我的问题是我混合了两个应用程序 App Id 和 Secret。有时我是个笨蛋,但问题是零警告或特定错误无处不在,所以这里列出了 Firebase 和其他插件可能会失败的事情:
在 Facebook Auth 的特定情况下(我发现 Google Sign In 更容易集成):
希望这可以帮助
我遇到了这个错误,但发生这种情况是因为我试图在我的应用程序上创建一个具有相同电子邮件地址的帐户,我必须从数据库和身份验证中删除该帐户。
我返回的代码与你的有点不同。
[FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@**5bfaa19**
Run Code Online (Sandbox Code Playgroud)
小智 3
这可能是由于您的测试设备上的 Google Play 服务版本不兼容。
如果是模拟器,请尝试切换到另一个映像并检查您是否使用的是最新版本的播放服务。
请注意,只有 Android N (API 24) 及更高版本支持通过 Playstore 更新播放服务。
归档时间: |
|
查看次数: |
31633 次 |
最近记录: |