在使用Kotlin协同程序时,与Room dao类错误

我试图使用kotlin协同程序通过这里描述的方法访问房间数据库,添加了插件和依赖项,并启用了gradle中的kotlin协程。

gradle文件中:

kotlin { experimental { coroutines 'enable' } } dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.21" ...} 

所以我为dao类中的所有方法添加了suspend关键字,如下所示:

道class

 @Query("select * from myevent") suspend fun all(): List @Delete suspend fun deleteEvent(event: MyEvent) ... 

并建立,然后得到这些错误

错误

e: C:\Users\projectpath\app\build\tmp\kapt3\stubs\debug\com\robyn\myapp\data\source\local\EventsDao.java:39: error: Deletion methods must either return void or return int (the number of deleted rows). public abstract java.lang.Object deleteEventById(@org.jetbrains.annotations.NotNull() ^ e: C:\Users\projectpath\app\build\tmp\kapt3\stubs\debug\com\robyn\myapp\data\source\local\EventsDao.java:41: error: Query method parameters should either be a type that can be converted into a database column or a List / Array that contains such type. You can consider adding a Type Adapter for this. kotlin.coroutines.experimental.Continuation p1);

错误链接导航到自动生成的 dao类。 这个类中生成的方法现在每个都有一个这种types的附加参数Continuation ,如下所示:

自动生成的dao类

 @org.jetbrains.annotations.Nullable() @android.arch.persistence.room.Delete() public abstract java.lang.Object deleteAllEvents(@org.jetbrains.annotations.NotNull() // error indicates at this line java.util.List events, @org.jetbrains.annotations.NotNull() kotlin.coroutines.experimental.Continuation p1); // error indicates at this line ... 

我尝试删除生成的dao类,并重新建立它,仍然得到这些错误。 我认为不使用lauch{}方法,而是使用suspend关键字,因为在代码中有许多地方要查询数据库。

我怎样才能解决这个问题?