Skip to content
Advertisement

Room database not created

I’m trying to develop an app with Room. The project is in java. This is my first time using Room.

I’ve followed the documentation and created class with @Database, @Dao & @Entity. However when I run the app, it throws the following exception.

Can someone please help me figure out what am I doing wrong here? I’ve spent a day on it but still couldn’t figure out.

JavaScript

Following are the classes:

Category.java:

JavaScript

MyDao.java:

JavaScript

MyDatabase.java:

JavaScript

ListConverter.java:

JavaScript

Build.gradle

JavaScript

Please help me understand where am I making a mistake.

Advertisement

Answer

The problem you’re facing is because of the java annotations eg. in this case @Database. Kotlin doesn’t play well with the java annotations, that’s one of the reasons I know which caused such problem (Database_Impl.java) not found.

In order to fix it in your java project, you need to update the dependencies like the following & change the highlighted part from annotationProcessor to implementation. I still need to understand why it works when changing to implementation so if someone can comment below, that’ll be really helpful.

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