RF_956
RF_956

Reputation: 341

Error: cannot find symbol/class Firebase in android studio

I am following the firebase assistant and video tutorial. I am receiving an error and it says that (see picture below)error

Here is my code:

enter image description here

enter image description here

I had the same problems with Button, EditText, and View; but I resolved that by adding import statements. Is there any way import Firebase?

Upvotes: 2

Views: 8163

Answers (2)

Vishal Yadav
Vishal Yadav

Reputation: 1024

  • Simply you goto Firebase Console and add your required dependecies like com.google.firebase:firebase-database:11.4.0 you have to add this line in your app/build.gradle
  • make sure have to add core dependency in app/build.gradle which is compile 'com.google.firebase:firebase-core:11.4.0'

android {
 // ...
}

dependencies {
// ...
compile 'com.google.firebase:firebase-database:11.4.0'
compile 'com.google.firebase:firebase-core:11.4.0'
}

 // ADD THIS AT THE BOTTOM
 apply plugin: 'com.google.gms.google-services'

  • in your build.gradle you've to add this snippet

buildscript {
// ...
dependencies {
    // ...
    classpath 'com.google.gms:google-services:3.1.0' // google-services 
  plugin
   }
  }

    allprojects {
   // ...
   repositories {
    // ...
    maven {
        url "https://maven.google.com" // Google's Maven repository
    }
    }
      }

Happy to help you

Upvotes: 1

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363815

Just import com.google.firebase.database.FirebaseDatabase

Upvotes: 2

Related Questions