Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Unresolved Reference

I have implemented Firebase database by included assistant. It added to my gradle dependencies implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'

after that, I couldnt build the procject (solution was to change impelentation into kapt)

My gradle looks like:

dependencies {
        kapt 'com.google.firebase:firebase-database:16.0.1:15.0.0'
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.android.support:design:28.0.0'
    }

Then, I needed to retreive a instance of my database

class AppActivity : AppCompatActivity() {

    val manager = supportFragmentManager


    var database = FirebaseDatabase.getInstance()

and its error, unresolved reference: FirebaseDatabase

I have tried to deal with it, but it seems its beyond me.

Guys, any idea what is the reason ?

like image 816
radekdob Avatar asked Jan 27 '23 05:01

radekdob


1 Answers

I face same problem today and I solve it by adding next line

implementation 'com.google.firebase:firebase-database-ktx:19.2.1'

but note I'm using higher ver. of Firebase

implementation 'com.google.firebase:firebase-database:19.2.1'`

As you using firebase-database:16.0.1:15.0.0 may you need to add next line

implementation 'com.google.firebase:firebase-database-ktx:16.0.1:15.0.0'

I hope it will work for you too.

Romuo

like image 168
Robot79 Avatar answered Jan 31 '23 18:01

Robot79