解决cannot find implementation AppDatabase

初始化room崩溃 ,第一行错误日志是

at androidx.room.Room.getGeneratedImplementation(Room.java:94)

解决方案:

需要参考官方文档:

https://developer.android.google.cn/training/data-storage/room?hl=zh_cn#groovy

gradle配置如下:

plugins {
    id 'kotlin-kapt'
}

dependencies {    
    def room_version = "2.3.0"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    implementation "androidx.room:room-ktx:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    // optional - RxJava2 support for Room
    implementation "androidx.room:room-rxjava2:$room_version"

    // optional - RxJava3 support for Room
    implementation "androidx.room:room-rxjava3:$room_version"

    // optional - Guava support for Room, including Optional and ListenableFuture
    implementation "androidx.room:room-guava:$room_version"

    // optional - Test helpers
    testImplementation "androidx.room:room-testing:$room_version"
}

你可能感兴趣的:(kotlin,解决问题,room崩溃,java,html)