I keep on getting this exception when first creating room database
  java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Package.getName()' on a null object reference
This is my room database code:
@Database(entities = [Channel::class], version = 1)
abstract class ChannelRoomDatabase : RoomDatabase() {
    abstract fun channelDao(): ChannelDao
    companion object {
        private var INSTANCE: ChannelRoomDatabase? = null
        fun getInstance(application: Application): ChannelRoomDatabase? {
            if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(application,
                            ChannelRoomDatabase::class.java,
                            "channels")
                            .build()
            }
            return INSTANCE
        }
    }
}
And the gradle code:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
    def room_version = "1.1.1"
    implementation "android.arch.persistence.room:runtime:$room_version"
    kapt "android.arch.persistence.room:compiler:$room_version"
Also I get this error when buliding the project:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
Folder /home/Desktop/MySendBird/app/build/generated/source/kaptKotlin/debug
Folder /home/Desktop/MySendBird/app/build/generated/source/kaptKotlin/release
3rd-party Gradle plug-ins may be the cause
What could be the reason? I have seen similar questions here but no any clue. Please help!
Update! In my Dao I get this error
So how to make @Query understand that it I give it a java String not Kotlin String
See also the stacktrace:
/home/Desktop/MySendBird/app/build/tmp/kapt3/stubs/debug/ChannelRoomDatabase.java:6: warning: Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.
public abstract class ChannelRoomDatabase extends android.arch.persistence.room.RoomDatabase {
                ^
:app:compileDebugKotlin
w: /home/Desktop/MySendBird/app/src/main/java/com/example/anna/mysendbird/repository/ChannelRepository.kt: (16, 13): Variable 'db' is never used
w: /home/Desktop/MySendBird/app/src/main/java/com/example/anna/mysendbird/repository/ChannelRepository.kt: (47, 23): Parameter 'channel' is never used
w: /home/Desktop/MySendBird/app/src/main/java/com/example/anna/mysendbird/view/MainActivity.kt: (179, 29): Parameter 'userId' is never used
See the similar questions:
using Room with kotlin, get exception when build the database

 
    