2

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?

6
  • Just use Alt + enter to import missing classes.
    – user6490462
    Commented Sep 23, 2017 at 18:50
  • Oh I see! :) Let me try that. Thanks. I've never used Java for almost 6 years. hahaha!
    – RF_956
    Commented Sep 23, 2017 at 18:55
  • Not working sir :(
    – RF_956
    Commented Sep 23, 2017 at 18:56
  • Well, it's not java that is doing that, it's A-S (The IDE)
    – user6490462
    Commented Sep 23, 2017 at 18:56
  • But, thanks. It is now working.
    – RF_956
    Commented Sep 23, 2017 at 18:56

2 Answers 2

2

Just import com.google.firebase.database.FirebaseDatabase

1
  • Hi @RF_956 if this or any answer has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. Commented Oct 3, 2017 at 10:37
1
  • 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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.