Gil G
Gil G

Reputation: 1869

Android kotlin and Room Persistences library not building

I'm trying to use Room with kotlin and nothing works it throws the following:

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]' 

In my Build.Gradle class, I have the following(Out of order but all the important info is here)

//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"

My module class

@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

}

My Dao class

@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 
}

Am i missing something or doing something wrong?

Upvotes: 1

Views: 883

Answers (1)

toteto
toteto

Reputation: 13

Had the same issue and thought that the warning was the issue.

After scrolling a bit up in the Event log I saw that my builds fails when Room checks if my SQL is good.

Please check the log, but i guess Room has hard time converting your

var users :ArrayList<String>

Upvotes: 1

Related Questions