我正在尝试将 Room 与 kotlin 一起使用,但没有任何效果,它会抛出以下内容:
Supported source version 'RELEASE_7' from annotation processor 'android.arch.lifecycle.LifecycleProcessor' less than -source '1.8'
Supported source version 'RELEASE_7' from annotation processor 'android.arch.persistence.room.RoomProcessor' less than - source '1.8'
The following options were not recognized by any processor: '[kapt.kotlin.generated]'
在我的 Build.Gradle 类中,我有以下内容(乱序但所有重要信息都在这里)
//project build.gradle
ext {
versions = [
support: '25.3.1',
dagger : '2.11',
arch_comp : '1.0.0-alpha1'
]
}
//app build.gradle
apply plugin: 'kotlin-kapt'
compile "android.arch.lifecycle:runtime:$rootProject.versions.arch_comp"
compile "android.arch.lifecycle:extensions:$rootProject.versions.arch_comp"
kapt "android.arch.lifecycle:compiler:$rootProject.versions.arch_comp"
compile "android.arch.persistence.room:runtime:$rootProject.versions.arch_comp"
compile "android.arch.persistence.room:rxjava2:$rootProject.versions.arch_comp"
kapt "android.arch.persistence.room:compiler:$rootProject.versions.arch_comp"
我的模块类
@Entity(tableName = "groups")
data class Group(@ColumnInfo(name = "group_name")
var groupName: String = "",
@ColumnInfo(name = "users")
var users :ArrayList<String> = ArrayList<String>()) {
@ColumnInfo(name = "id")
@PrimaryKey(autoGenerate = true)
var id: Long = 0
}
我的道课
@Dao
interface GroupDao {
@Query("SELECT * FROM groups")
fun getAll() : LiveData<ArrayList<Group>>
@Query("SELECT * FROM groups WHERE group_name = :p0")
fun getGroupByName(groupName: String) : Group
//I also did this but with no succsess instade of the above
@Query("SELECT * FROM groups WHERE group_name = :arg0")
fun getGroupByName(groupName: String) : Group
}
我错过了什么或做错了什么?