Skip to content
Advertisement

I am getting error in firebase database function get()

I am facing a problem for 2-3 days I am trying to fix it but I can’t fix it. I am continuously getting errors on a Firebase Realtime Database function get() on a code that I have copied from Firebase Realtime Database documentation. Here is my code:

JavaScript

Build.gradle:

JavaScript

I am getting error on compiling code that is:

The method get() is undefined for the type DatabaseReference

Advertisement

Answer

The get() method isn’t recognized because you’re using an old version of the Realtime Database dependency. The get() method is available starting from version 19.6.0.

To be able to use get(), you need to update the dependency to the latest available version, which is:

JavaScript

But I strongly advise you to use the BOM version without specifying the version for each product that you’re using:

JavaScript

If you’re using Kotlin, here are the corresponding dependencies:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement