RoomDB 和 Kotlin 协程发生了什么?我一次又一次地尝试在 Room Dao 中使用挂起功能,但每次都会显示错误。我什至遵循 android codelabs 示例。但它又显示错误。如果我在 Dao 中编写暂停,应用程序甚至不会构建。但如果我删除 suspend 关键字,它就会成功构建。
它显示以下错误:
error: Type of the parameter must be a class annotated with @Entity or a collection/array of it.
kotlin.coroutines.Continuation<? super kotlin.Unit> continuation);
Run Code Online (Sandbox Code Playgroud)
我的实体:
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "vocabulary")
class Vocabulary(
@PrimaryKey(autoGenerate = true)
val vocabularyId: Long,
val word: String,
val meaning: String,
val definition: String,
val example: String,
val partsOfSpeech: String,
val synonyms: String,
val antonyms: String,
val phonetics: String,
val folderId: Long,
val …Run Code Online (Sandbox Code Playgroud) android kotlin android-studio android-room kotlin-coroutines