错误: Not sure how to handle query method‘s return type (long). UPDATE query methods must either re...
找了好久,都被标题党给赚流量了而不给解决方案
·
room_version=2.4.2 会报一下错误 下面是我的写的demo 中Dao部分
@Dao
interface CarBrandDao {
// TODO 这里有BUG 返回suspend就会报错
@Query("DELETE FROM CarBrandEntity")
suspend fun clearCarBrand()
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertCarBrand(carBrandList: List<CarBrandEntity>)
@Query("SELECT * FROM CarBrandEntity")
fun getCarBrand():PagingSource<Int,CarBrandEntity>
}
在网上找了好久,才找到对应的解决方案,深渊巨坑,在之前的一个demo 中也遇到类似的问题,不过没有去处理,现在终于决绝。 解决方式一: If you using kotlin version (1.7.0) should work with room latest alpha version (2.5.0-alpha02) classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0" implementation "androidx.room:room-runtime:2.5.0-alpha02" implementation "androidx.room:room-ktx:2.5.0-alpha02" kapt "androidx.room:room-compiler:2.5.0-alpha02" 解决方式二: If you want using room in stable version (2.4.2) should work with kotlin version (1.6.20) classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20" implementation "androidx.room:room-runtime:2.4.2" implementation "androidx.room:room-ktx:2.4.2" kapt "androidx.room:room-compiler:2.4.2" I have tried both and they work. this is the reference 文章来源 原文---stackoverflowhttps://stackoverflow.com/questions/60050991/how-to-use-suspend-function-on-room-db 一下是对应的issues issueshttps://issuetracker.google.com/issues/236612358
更多推荐


所有评论(0)