本文介绍了Firebase 身份验证 FirebaseNetworkException:发生网络错误(例如超时、连接中断或主机无法访问)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的 Android 应用创建一个身份验证工作流程.我允许用户使用用户名/密码和各种 OAuth 提供商登录.我正在验证电子邮件和密码,以便我知道我传递给 Firebase 的信息是有效的.我正在使用 com.google.firebase:firebase-auth:9.6.1

I'm creating an authentication workflow for my android app. I'm allowing users to sign in with username/password and various OAuth providers. I'm validating emails and password so that, I know the information I'm passing to Firebase is valid. I'm using com.google.firebase:firebase-auth:9.6.1

当我执行以下代码时,我收到一个回调,提示操作不成功并出现错误.

When I execute the following code, I get a callback that says the operation not successful with an error.

mFirebaseAuth.signInWithEmailAndPassword(username,password).addOnCompleteListener(this);

回调函数或完成监听器告诉我

Callback function or completion listener tells me

com.google.firebase.FirebaseNetworkException: A network error (such as timeout, interrupted connection or unreachable host) has occurred.

我传递的用户名还不存在.因此,我假设会看到某种错误,指出用户不存在.我是否错误地传递了某些东西还是我假设错误?我还可以看到,在 Firebase 文档中,iOS 库具有所有 API 方法部分通用的各种错误代码,而 Android 部分没有显示这一点.这些例外之一是 FIRAuthErrorCodeUserNotFound.那么,Android 库中是否存在该功能?

The username I'm passing doesn't exist yet. So, I would assume to see some kind of error stating the user doesn't exist. Am I passing something incorrectly or am I assuming incorrectly? I can also see that in the Firebase documentation, the iOS library has a various error codes common to all API methods section where as the Android section doesn't show this. One of these exceptions is FIRAuthErrorCodeUserNotFound. So, does that functionality even exists in the Android library?

推荐答案

当 google play 服务未运行时也会发生这种情况.尝试启动 Play 商店并检查它是否正常工作.如果没有重启设备问题.同时比较项目中使用的google play服务,如果不更新google play服务,设备中的google play服务是否相同.

It can also happen when google play services are not running. Try to launch play store and check if it is working. If not reboot of device issue.And also compare the google play services using in the project and google play services in the device are same if not update google play services.

这只是一个次要但可能出现异常的情况.

This is just a minor but possible case where it gives the exception.

这篇关于Firebase 身份验证 FirebaseNetworkException:发生网络错误(例如超时、连接中断或主机无法访问)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 14:05