I when try to implement a Room Database, I get the following error:
java.lang.RuntimeException: cannot find implementation for com.udacity.gradle.builditbigger.Database.HilarityUserDatabase. HilarityUserDatabase_Impl does not exist
at android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:92)
I tried adding the relevant kotlin dependencies to my gradle file (shown below) but when I do, all of my Databinding classes that would normally be generated with any issues are now generating errors in my gradle console. Is there way for me to use the DataBinding library and the Room Pesistence Library?
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
...
dependencies{
kapt "android.arch.persistence.room:compiler:1.0.0"
}
Make sure kotlin-kapt is included in app-level gradle file.
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
and make sure you use kapt instead of annotationProcessor. That solved my problem.
And also check Room Model, DAO, and Database files for @Entity, @Dao and @Database annotations.
I was facing the same issue, later found that I am not using the @Database annotation for AppDatabase
Use this
@Database(entities = {RowEntity.class, WifiDetailEntity.class}, version = 1)
public abstract class AppDatabase extends RoomDatabase
{ ...
It did happen to me before, make sure that you have all 3 dependencies in build.gradle
implementation 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
kapt 'android.arch.persistence.room:compiler:1.0.0'
Also, a "Project Clean" after gradle synch will help as well.
For usage of Room, LiveData and ViewModel you need these libraries:
•implementation "android.arch.persistence.room:runtime:1.0.0"
•implementation "android.arch.lifecycle:extensions:1.1.0"
•kapt "android.arch.persistence.room:compiler:1.0.0"
•kapt "android.arch.lifecycle:compiler:1.1.0"
LiveData and ViewModel allows you to use the DataBinding technique.
For more info check the official page: https://developer.android.com/topic/libraries/architecture/adding-components.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With