Devrath
Devrath

Reputation: 42824

Unresolved reference displaying in kotlin android

I am using room persistence library and dagger

RoomModule.kt

@Module
class RoomModule {

    @Provides
    @Singleton
    internal fun provideMoviesAppDatabase(application: Application): MoviesAppDatabase {
        return Room.databaseBuilder<MoviesAppDatabase>(application, KtMoviesAppDatabase::class.java, Keys.DATABASE_NAME)
                .addCallback(object : RoomDatabase.Callback() {
                    override fun onCreate(db: SupportSQLiteDatabase) {}
                    override fun onOpen(db: SupportSQLiteDatabase) {}
                })
                .build()
    }

}

KtMoviesAppDatabase.kt

@Database(entities = [Movie::class], version = 1)
abstract class KtMoviesAppDatabase : RoomDatabase() {
    abstract fun getMovieDAO(): MovieDAO
}

Error I am getting:

enter image description here


{EDIT}

I made some changes

@Module
class RoomModule {

    @Provides
    @Singleton
    internal fun provideMoviesAppDatabase(application: Application): KtMoviesAppDatabase {
        return Room.databaseBuilder<KtMoviesAppDatabase>(application, KtMoviesAppDatabase::class.java, Keys.DATABASE_NAME)
                .addCallback(object : RoomDatabase.Callback() {
                    override fun onCreate(db: SupportSQLiteDatabase) {}
                    override fun onOpen(db: SupportSQLiteDatabase) {}
                })
                .build()
    }

}

Still I have the error :

Unresolved reference: java

Upvotes: 3

Views: 1454

Answers (2)

Ramindu Iranga
Ramindu Iranga

Reputation: 1

I had this error earlier time and I solved this problem by updating the android studio you can update using this path (help > check for updates...)

Upvotes: 0

Devrath
Devrath

Reputation: 42824

Very Silly mistake since I had not added proper dependencies

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.core:core-ktx:1.0.2'

Upvotes: 3

Related Questions