Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RoomDatabase_Impl does not exist

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"
}
like image 317
Joel Robinson-Johnson Avatar asked Mar 11 '18 20:03

Joel Robinson-Johnson


4 Answers

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.

like image 167
Arkar Min Tun Avatar answered Oct 23 '22 01:10

Arkar Min Tun


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

{ ...

like image 20
imok1948 Avatar answered Oct 23 '22 02:10

imok1948


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.

like image 22
MhzDev Avatar answered Oct 23 '22 02:10

MhzDev


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

like image 1
Erick Avatar answered Oct 23 '22 02:10

Erick