'Name expected in kotlin

I am getting an error and im not sure why, I've tried a few different solutions ive found online and nothing has worked.

@Database(entities = {Tea.class}, version = 1, exportSchema = false)

the error im getting is that "Name expected" for after {Tea/class}

package com.google.developers.teacup.data

import android.content.Context
import androidx.room.Database
import androidx.room.Entity
import androidx.room.RoomDatabase
@Entity
@Database(entities = {Tea.class}, version = 1, exportSchema = 
false)
abstract class TeaDatabase: RoomDatabase() {

    abstract fun teaDao(): TeaDao

    companion object {

    @Volatile
    private var instance: TeaDatabase? = null

    /**
     * Returns an instance of Room Database
     *
     * @param context application context
     * @return The singleton TeaDatabase
     */
    fun getInstance(context: Context): TeaDatabase {

    return(instance!!)}
    }
}


Solution 1:[1]

As per Kotlin syntax, you need to replace Tea.class with Tea::class

@Database(entities = {Tea::class}, version = 1, exportSchema = false)

Remove @Entity from your TeaDatabase class and add it to Tea.class.

Hope it should solve your problem.

Solution 2:[2]

Entities is supposed to be an array, so in Kotlin it should be defined with [], meaning your @Database line should be:

@Database(entities = [Tea::class], version = 1, exportSchema = false)

(bearing in mind what Shailendra Madda said about using Tea::class instead of Tea.class)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shailendra Madda
Solution 2 tymwitko