UPDATE: tried Mike's suggestion, still get error:
ext {
kotlin_version = '1.1.50'
arch_lib_version = '1.0.0-alpha9'
gradle_version = '2.3.3'
}
kapt {
generateStubs = true
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "android.arch.lifecycle:runtime:$arch_lib_version"
compile "android.arch.lifecycle:extensions:$arch_lib_version"
compile "android.arch.persistence.room:runtime:$arch_lib_version"
//annotationProcessor "android.arch.persistence.room:compiler:$arch_lib_version"
kapt "android.arch.persistence.room:compiler:$arch_lib_version"
annotationProcessor "android.arch.lifecycle:compiler:$arch_lib_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
Error:Annotation processor '__gen.AnnotationProcessorWrapper_robotiumDebug_android_arch_persistence_room_RoomProcessor' not found
============
in gradle:
ext {
arch_lib_version = '1.0.0-alpha9'
}
compile "android.arch.persistence.room:runtime:$arch_lib_version"
annotationProcessor "android.arch.persistence.room:compiler:$arch_lib_version"
//kapt "android.arch.persistence.room:compiler:$arch_lib_version"
tried using the kapt, it will give compile error:
Error:Annotation processor '__gen.AnnotationProcessorWrapper_robotiumDebug_android_arch_persistence_room_RoomProcessor' not found
the code snippet is below:
@Database(entities = arrayOf(CModel::class), version = 1)
abstract class CDatabase : RoomDatabase() {
abstract fun cModel(): DbCDao
companion object {
fun getDatabase(context: Context): CDatabase {
return Room.databaseBuilder(context.applicationContext, CDatabase::class.java, “database”)
.build() //<=== throw here saying CDatabase_Impl does not exist
}
}
}
the table clas:
@Entity(tableName = “table”)
class CModel() : ICDelegate {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = “index")
private var mIndex: Long = -1
@ColumnInfo(name = "parentIndex")
private var mParentIndex: Long = -1
……
}
the Dao interface defination:
@Dao
interface DbCDao {
@Query("select * from table")
fun loadAllAccountss(): List<CModel>
@Query("select * from table where index = :index")
fun loadCsByIndex(index: Int): CModel
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertC(ac: CModel) : Long
@Update(onConflict = OnConflictStrategy.REPLACE)
fun updateAC(ac: CModel) : Int
@Delete
fun deleteAc(ac: CModel) : Int
@Query("DELETE FROM table”)
fun deleteAllCs()
}
the exception:
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by:
java.lang.RuntimeException: cannot find implementation for com.myproject.data. CDatabase. CDatabase_Impl does not exist
at
android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:90)
at
android.arch.persistence.room.RoomDatabase$Builder.build(RoomDatabase.java:440)
tried someone suggested and does not work:
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}