在firebaseAuth中获取错误“无法解析符号getInstance”

pw136qt2  于 2023-10-22  发布在  其他
关注(0)|答案(1)|浏览(108)
protected void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ...
    firebaseAuth = new FirebaseAuth.getInstance();

在-> getInstance()中获取错误

}
public void registerUser(){
... 
firebaseAuth.createUserWithEmailAndPassword(email,password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if(task.isSuccessful()){
                        Toast.makeText(MainActivity.this,"Registered successfully",Toast.LENGTH_SHORT).show();
                    }else {Toast.makeText(MainActivity.this,"Registered unsuccessful",Toast.LENGTH_SHORT).show();}
                }
            });

我已经正确地将Firebase与我的项目同步,但出现此错误。

wz3gfoph

wz3gfoph1#

查看FirebaseAuth.getInstance()documentation。它是一个静态方法,返回默认的FirebaseAuth。你不想创建一个新的示例,你想要现有的默认示例。
变更:

firebaseAuth = new FirebaseAuth.getInstance()

收件人:

firebaseAuth = FirebaseAuth.getInstance()

相关问题