DatabaseReference and FirebaseDatabase - cannot resolve symbol

cannot resolve symbol storagereference
cannot resolve symbol 'firebase
databasereference error
firebase-database dependency
cannot resolve symbol firebaseuser
cannot resolve symbol firebase-firestore
firebase database android
firebase database kotlin

I'm currently working on an institute level chat messaging application on Android. I'm using Firebase as my Cloud Server. Currently, I'm facing a Cannot Resolve Symbol error on DatabaseReference and FirebaseDatabase at the following line in my MainActivity:

private DatabaseReference root = FirebaseDatabase.getInstance().getReference().getRoot();

I want to make chat rooms using Firebase. I know how to do this, as well as how to link Keys and Values of my Firebase Database. I also know how to update the Keys and Values from an Android Device through Firebase Cloud.

But I'm not able to resolve the Cannot resolve Symbol error. Following is the code of my MainActivity. I'm still in initial stages of making this app.

    package com.ranatalha.realtimechat;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private Button buttonAddRoom;
    private EditText editTextAddaChatRoom;
    private ListView listViewChatRooms;

    private ArrayAdapter<String> arrayAdapter;
    private ArrayList<String> list_of_rooms = new ArrayList<>();

    private String Entered_Username;


    private DatabaseReference root = FirebaseDatabase.getInstance().getReference().getRoot();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        buttonAddRoom = (Button) findViewById(R.id.buttonAddRoom);
        editTextAddaChatRoom = (EditText) findViewById(R.id.editTextAddaChatRoom);
        listViewChatRooms = (ListView) findViewById(R.id.listViewChatRooms);

//************Creation of an array list to store the list of active chat rooms************
        arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, list_of_rooms);

        listViewChatRooms.setAdapter(arrayAdapter);
//*****************************************************************************************
        request_user_name();

        buttonAddRoom.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
    }
    private void request_user_name(){

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Enter Your Name:");

        final EditText inputUsername = new EditText(this);
        builder.setView(inputUsername);

        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Entered_Username = inputUsername.getText().toString();

            }
        });

        builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
                request_user_name();
            }
        });

        builder.show();

    }
}

Can you please double check if you have these dependencies into your build.gradle (Module:app) file?

implementation 'com.google.firebase:firebase-analytics:17.2.1'    
implementation 'com.google.firebase:firebase-database:19.2.0'

The error goes away after adding those.

Android Studio - Cannot resolve symbol 'firebase', I get a "cannot resolve symbol 'firebase'" in my imports i.e. import com.google.​firebase.database.DatabaseReference; . Those are not errors  Home » Android » android – DatabaseReference and FirebaseDatabase – cannot resolve symbol android – DatabaseReference and FirebaseDatabase – cannot resolve symbol Posted by: admin May 11, 2020 Leave a comment

You need to add these dependencies into your

1) build.gradle (Module:app) file.

implementation 'com.google.firebase:firebase-database:11.6.2'

2) build.gradle (Top-level build)

classpath 'com.google.gms:google-services:3.1.0'

3) add google-services.json in app module in Android Studio

Android Studio - Cannot resolve symbol 'firebase', I'm using Firebase as my Cloud Server. Currently, I'm facing a Cannot Resolve Symbol error on DatabaseReference and FirebaseDatabase at the following line​  I get a “cannot resolve symbol ‘firebase'” in my imports i.e. import com.google.firebase.database.DatabaseReference;. Those are not errors that appear when building, so this seems to be working, but they are visible in the code editor of Android Studio.

implementation 'com.google.firebase:firebase-core:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'

Android: cannot resolve symbol FirebaseDatabase, I get a "cannot resolve symbol 'firebase'" in my imports i.e. import com.google.​firebase.database.DatabaseReference;. Those are not errors that appear when  public class DatabaseReference extends Query A Firebase reference represents a particular location in your Database and can be used for reading or writing data to that Database location. This class is the starting point for all Database operations.

Android Studio - Cannot resolve symbol 'firebase', Android: cannot resolve symbol FirebaseDatabase. 92 Views. 0. Votes. name firebase related. DatabaseReference myRef = database. A Firebase reference represents a particular location in your Database and can be used for reading or writing data to that Database location. This class is the starting point for all Database operations. After you've initialized it with a URL, you can use it to read data, write data, and to create new DatabaseReferences.

How do I do? Error: cannot find symbol method getdownloadurl , I get a "cannot resolve symbol 'firebase'" in my imports i.e. import com.google.​firebase.database.DatabaseReference; . Those are not errors that appear when  Cannot Resolve symbol 'addValueEventListener' despite the fact I have ValueEventListener imported. (It might be important to note that ValueEventListener is displayed in the IDE as an unused import, even though I'm clearly attempting to use it)

com.google.firebase.database, databaseReference = FirebaseDatabase.getInstance().getReference(​Database_Path); //Assign ID'S to button. ChooseButton = findViewById(R.id. The following are top voted examples for showing how to use com.google.firebase.database.DatabaseReference. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.

Comments
  • Show us your app-level build.gradle
  • For this guide with special attention to adding the SDK.
  • @Arel suggested an answer and it worked like a charm. I added 2 more dependencies in my build.gradle (Module:app) file which are compile 'com.google.firebase:firebase-core:9.4.0' and compile 'com.google.firebase:firebase-database:9.4.0' ... Thanks a lot for your reply and concern to my question @qbix and @AbAppletic :)
  • This worked. Thanks a lot @Arel for helping me with this. Really grateful to you for this :)
  • No problem. Happy Coding!
  • That did fix it. I didn't see that in the firebase.google.com walkthru setup guide. I guess it is missing from that?
  • Hi @daylight If you haven't seen the docs yet, you may read it here firebase.google.com/docs/android/setup#manually_add_firebase