FirebaseAuth:getGoogleApiForMethod()返回了Gms:com.google.firebase.auth.api.internal.zzal@489 [英] FirebaseAuth: getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@489

查看:64
本文介绍了FirebaseAuth:getGoogleApiForMethod()返回了Gms:com.google.firebase.auth.api.internal.zzal@489的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试进行电话验证时,我遇到了错误提示.

When I am trying to phone authntication I am getting below error.

W/BiChannelGoogleApi(12340): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@489

我已经在Stackverflow和其他地方检查了相同的错误,但是在任何地方都没有找到正确的解决方案.

I have checked the same error in Stackverflow and other places but not getting proper solution anywhere.

更改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

注意-添加了////高亮显示我在上述文件中添加的行.

Note -- added //New to highlite the lines which i have added in above file.

app/build.gradle

apply plugin: 'com.google.gms.google-services'

android/build.gradle

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
}

android/app/build.gradle

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'

android/app/gradle.properties

android/app/gradle.properties

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

我正在使用AndroidX.

I am using AndroidX.

推荐答案

我在此上花了几个小时,所以让我分享一下我的经验.

I lost a few hours on this one, so let me share my experience on this.

Gms代表"Google移动服务",它基本上是Android的附加API由Google开发,可以连接到Google提供的一系列服务. 如果您使用flutter,则可能会被您使用的flutter程序包所包装,例如firebase_auth,flutter_facebook_login或/和google_sign_in.

Gms stands for "Google Mobile Services", and its basically an addon API to Android developed by Google that allows to connect to a bunch of Google-provided services. If you use flutter, this is probably wrapped by flutter packages you use such as firebase_auth, flutter_facebook_login or/and google_sign_in.

该错误有时可能是由更高级别的组件处理的,因此,如果您遇到该错误,并不表示您的配置错误或无法正常工作. 就我而言,使用Google登录进行登录时,我遇到此错误并获得成功的最终结果,如下所示:

This error may sometimes be handled by the higher level components, so if you have that error, it doesn't mean your configuration is wrong or it won't work. In my case I had this error with successful end result when I was logging using Google Sign in, something like this:

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....

我的代码中有一个飞镖调用print(fireUser);,因此我们认为它是成功的.

I have a dart call print(fireUser); in my code so we see it's a success.

但是在Facebook Auth的情况下,我只是遇到了这个问题,此后什么也没有发生,但是在Facebook服务器端,登录成功了,因为我可以在Facebook开发控制台中看到事件.

But in the case of Facebook Auth, I just had this, and nothing happened after that, but on the Facebook server side, login was succeeding as I could see events in Facebook dev console.

info flutter.tools W/BiChannelGoogleApi( 4106): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak@8116b2c

由于日志中没有其他内容,因此在此过程中有些卡住了.

And nothing else after in the log, so something was stuck in the process.

我的问题是我将两个应用程序App Id和Secret混合在一起.有时候我很头脑清醒,但问题是没有零警告或特定错误,所以这里列出了Firebase和其他插件可能失败的事情:

My problem was I mixed two applications App Id and Secret. I'm a bonehead sometimes, but the thing is there's zero warning or specific error nowhere, so here are a list of things that can fail with Firebase and other plugins:

  • 确保您已在Firebase控制台中正确配置了登录提供程序(google,facebook等)
  • 升级所有Flutter软件包.我个人不使用软件包版本,而是使用所有flutter软件包的最新版本.我使用的是AndroidX.

在Facebook Auth的特定情况下(我发现Google Sign In易于集成):

In the specific case of Facebook Auth (I find Google Sign In much easier to integrate):

  • 确保您在看好的应用程序
  • 确保应用程序ID"和应用程序密码"是正确的.在Facebook开发者控制台中,在此处检查基本设置".
  • 确保您已添加"Facebook登录"产品.如果您没有在左侧菜单中看到它,请在Facebook开发控制台中,检查仪表板并添加它.
  • 在"Facebook登录名"产品设置中,确保已添加Firebase控制台为您提供的有效OAuth重定向URI"(在Facebook登录提供程序配置中).您可以在该页面下方的重定向URI验证程序"工具中对其进行检查.
  • 在应用程序的基本设置"中,如果您使用flutter(=>移动平台),请确保您具有IOS部分/平台和Android部分/平台.要实现此目的,您可以手动添加平台"或使用快速入门".
  • 最后,"IOS"部分只能包含捆绑ID"
  • 和Android部分应包含"Google Play包名称",类名称"和至少一个键哈希"(用于调试).如果您不知道如何创建哈希,请使用"Facebook登录"快速入门.

希望这会有所帮助

这篇关于FirebaseAuth:getGoogleApiForMethod()返回了Gms:com.google.firebase.auth.api.internal.zzal@489的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆