Android room persistent: AppDatabase_Impl does not exist

前端 未结 21 1393
日久生厌
日久生厌 2020-11-29 01:09

My app database class

@Database(entities = {Detail.class}, version = Constant.DATABASE_VERSION)
public abstract class AppDatabase extends RoomDatabase {

            


        
相关标签:
21条回答
  • 2020-11-29 01:16

    For Kotlin Developers


    if you checked Dao and Entity and also used Kapt and there is no problem, I guess there is a problem with your kotlin version if you are using kotlin 1.4 and above. update Room to last version from this link.


    2.3.0-alpha03 solved my problem.

    0 讨论(0)
  • 2020-11-29 01:18

    It is not just about updating your dependencies. Make sure all your Room dependencies have the same version.

    implementation 'android.arch.persistence.room:rxjava2:1.1.0-alpha2'
    implementation 'android.arch.persistence.room:runtime:1.1.0-alpha2'
    annotationProcessor "android.arch.persistence.room:compiler:1.1.0-alpha2"
    

    In the sample snippet above, all my Room dependencies have the same version 1.1.0-alpha2

    0 讨论(0)
  • 2020-11-29 01:21

    The issue is more around the correct library that is not included in the gradle build. I had a similar issue and added the missing

    testImplementation "android.arch.persistence.room:testing:$room_version

    0 讨论(0)
  • 2020-11-29 01:22

    For Kotlin Developers

    Use this:

    implementation "android.arch.persistence.room:runtime:1.0.0"
    kapt "android.arch.persistence.room:compiler:1.0.0"
    

    And add apply plugin: 'kotlin-kapt' to the top of the app level build.gradle.

    For Java Developers

    implementation "android.arch.persistence.room:runtime:1.0.0"
    annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
    
    0 讨论(0)
  • 2020-11-29 01:23

    make sure to add correct dependency for room in build.gradle

    ext {
       roomVersion = '2.1.0-alpha06'
    }
    
    // Room components
    implementation "androidx.room:room-runtime:$rootProject.roomVersion"
    implementation "androidx.room:room-ktx:$rootProject.roomVersion"
    kapt "androidx.room:room-compiler:$rootProject.roomVersion"
    androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
    

    And below line at the top-

    apply plugin: 'kotlin-kapt'
    
    0 讨论(0)
  • 2020-11-29 01:23

    In my case, I was testing the connectivity for room database and I have put the testing class inside the directory which I have created inside the AndroidTest folder. I have moved it out of the custom directory, then it worked pretty well.

    0 讨论(0)
提交回复
热议问题