【问题标题】:Firebase Authentication issue getGoogleApiForMethod() returned GmsFirebase 身份验证问题 getGoogleApiForMethod() 返回 Gms
【发布时间】:2017-12-10 22:33:43
【问题描述】:

在我的新 Android 应用(使用 MVP 架构)中,我当前的 Firebase 身份验证和实时数据库 (RTDB) 实现。而不是将 AuthStateListener 逻辑放在我的 MainActivity View 类中。我把它放在 Presenter 类中。 Presenter 类附加或分离监听器以响应视图生命周期(onResume 调用在presenter 中附加监听器,onPause 调用在presenter 中分离监听器)。

问题:在设备变为非活动状态(可能服务器关闭连接)后,再次变为活动状态。用户仍处于登录状态(预期行为),但出乎意料的是,已登录用户无法再访问 Firebase RTDB,但 RTDB 并未引发任何读/写权限被拒绝错误。从那一刻起,任何数据库读/写操作都将不起作用,从 Firebase 控制台确认。

出现此问题时,log cat 反复显示以下警告,似乎是一种退避登录尝试策略?

12-10 14:09:23.671 13076-13271/appname W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms

12-10 14:09:27.191 13076-13271/ appname W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms

12-10 14:09:28.182 13076-13271/ appname W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms

12-10 14:09:29.659 13076-13271/ appname W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms

如果用户退出,然后重新登录并再次激活,该问题将得到解决。当用户处于活动状态时,任何新的读/写操作都会执行,但之前的操作不会持久化或重试。

我使用的相关版本是

// Firebase
implementation "com.firebaseui:firebase-ui-auth:3.1.0"
implementation "com.google.firebase:firebase-database:11.6.2"
implementation "com.google.firebase:firebase-auth:11.6.2"

对于在 Android 应用的 MVP 结构中使用数据库实现 Firebase 身份验证,是否有任何最佳实践信息?

【问题讨论】:

  • set()update() 调用中是否有侦听器来检查失败并记录异常消息?或者您是否仅通过 Firebase 控制台数据库视图中没有更改来判断失败。
  • 你能弄清楚为什么会这样吗?我遇到了同样的问题。

标签: android firebase firebase-realtime-database firebase-authentication


【解决方案1】:

你应该使用

firebase-database = '11.6.2' 
firebase-ui-auth = '3.1.0'

也是。

【讨论】:

  • 对不起,如果我不清楚依赖关系,我将这些版本与 fb 数据库和 ui-auth 一起使用。见编辑谢谢。
【解决方案2】:

这只是发生在我身上类似的警告,电子邮件/密码身份验证问题...这是我升级计算机操作系统后忘记更新项目的 SHA-1 指纹...在您的情况,也许与您的 API 密钥有关?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-07
    • 1970-01-01
    • 1970-01-01
    • 2020-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    相关资源
    最近更新 更多