本文介绍了FirebaseAuth.getInstance()为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新了com.google.firebase:firebase-core:16.0.7com.google.firebase:firebase-auth:16.1.0,但是我没有更改代码中的任何内容,现在FirebaseAuth.getInstance()为空.

I updated com.google.firebase:firebase-core:16.0.7 and com.google.firebase:firebase-auth:16.1.0 but I didn't changed anything in my code and now FirebaseAuth.getInstance() is null.

java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.auth.FirebaseUser com.google.firebase.auth.FirebaseAuth.getCurrentUser()' on a null object reference

我要检查用户是否使用FirebaseAuth.getInstance().getCurrentUser()

I want to check if the user is signed in or not with FirebaseAuth.getInstance().getCurrentUser()

在gradle同步时出现这些错误(但已成功完成):

And I get these errors while gradle sync(but it was completed successfully):

推荐答案

我发现了此错误的原因.由于依赖性,我将tools:node="replace"添加到了AndroidManifest.xml中.当我将其删除时,一切又恢复正常了.

I found out the reason for this error. I added tools:node="replace" to my AndroidManifest.xml because of a dependency. As I removed it all worked fine again.

这篇关于FirebaseAuth.getInstance()为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 09:09