本文介绍了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?

推荐答案

当谷歌播放服务没有运行时也会发生这种情况。尝试启动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:04