Reputation: 147
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 ?
Upvotes: 4
Views: 14823
Reputation: 85
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
Upvotes: 8
Reputation: 80914
Change this:
kapt 'com.google.firebase:firebase-database:16.0.1:15.0.0'
into this:
implementation 'com.google.firebase:firebase-database:16.0.4'
check this for more information:
https://firebase.google.com/support/release-notes/android
Upvotes: 1