Lokesh Soni
Lokesh Soni

Reputation: 37

Getting error "cannot resolve symbol getInstance" in firebaseAuth

    protected void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ...
    firebaseAuth = new FirebaseAuth.getInstance();

getting error in -> 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();}
                }
            });

I have synced Firebase with my project properly but getting this error.

Upvotes: 1

Views: 8127

Answers (1)

Bob Snyder
Bob Snyder

Reputation: 38299

Look at the documentation for FirebaseAuth.getInstance(). It is a static method that returns the default FirebaseAuth. You don't want to create a new instance, you want the existing default instance.

Change:

firebaseAuth = new FirebaseAuth.getInstance()

to:

firebaseAuth = FirebaseAuth.getInstance()

Upvotes: 9

Related Questions