【问题标题】:Coroutines bug in android with Kotlin 1.6带有 Kotlin 1.6 的 android 中的协程错误
【发布时间】:2022-01-07 10:21:55
【问题描述】:

我刚把kotlin从1.5更新到1.6,还有这个功能

    @Query("SELECT * FROM Noticia")
suspend fun selectAll() :List<Noticia>

给我以下错误:

error: Not sure how to convert a Cursor to this method's return type (java.lang.Object).
public abstract java.lang.Object selectAll(@org.jetbrains.annotations.NotNull()

我猜是因为 kotlin 的新版本,但我不确定

【问题讨论】:

  • 从定义中删除suspend
  • 尝试清理项目,然后重建项目
  • 我尝试了所有这些但没有奏效,当我从函数中删除暂停时给我这个错误:java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.

标签: android kotlin-coroutines android-studio-3.0


【解决方案1】:

我使用的是过时的房间版本,我所做的只是将房间版本更改为:

    def room_version = "2.3.0"

【讨论】:

    猜你喜欢
    • 2019-12-10
    • 2020-01-21
    • 1970-01-01
    • 2019-11-28
    • 1970-01-01
    • 2018-05-18
    • 2020-09-11
    • 2018-07-20
    • 1970-01-01
    相关资源
    最近更新 更多