Room “Not sure how to convert a Cursor to this method's return type”: which method?

后端 未结 20 1434
遇见更好的自我
遇见更好的自我 2020-12-14 14:15
Error:Not sure how to convert a Cursor to this method\'s return type
Error:Execution failed for task \':app:compileDebugJavaWithJavac\'.
Compilation failed; see the          


        
20条回答
  •  太阳男子
    2020-12-14 14:58

    I Spend the entire day on this issue. the solution was very simple. I was using something like this before

    @Query("SELECT * FROM myTable")
    fun getAll(): MutableLiveData>
    

    Now when I changed ArrayList to List & MutableLiveData to LiveData it is working fine.

    @Query("SELECT * FROM myTable")
    fun getAll(): LiveData>
    

    based on the answers & comments on this issue I think room support only List & LiveData because I tried with on MutableLiveData & only ArrayList too. none of the combinations worked.

    Hope this will help someones few hours.

提交回复
热议问题