使用room时报的错,gradle里是这样写的:
plugins {
……
id 'kotlin-kapt'
}
dependencies {
……
implementation "androidx.room:room-runtime:2.4.2"
kapt "androidx.room:room-compiler:2.4.2"
}
Execution failed for task ‘:app:kaptDebugKotlin‘.异常
文章说把kapt改成annotationProcesser就可以了,但是还是有问题。
cannot find implementation for XXX. XXX_Impl does not exist
按照流程,先检查了一下注解是否都添加了
@Database:表示数据库.
@Entity:表示数据库中的表。
@DAO:包含用于访问数据库的方法。
果然,少了dao,添加之后没有报错,即不能使用annotationProcesser,因为项目使用的是kotlin语言,遂改成kapt ,成功。