Architecture-components-samples: Paging : Not sure how to convert a Cursor to this method's return type

Created on 9 Oct 2017  路  11Comments  路  Source: android/architecture-components-samples

I am getting error for LivePagedListProvider Return type while compiling

Error:(22, 58) error: Not sure how to convert a Cursor to this method's return type

@Dao
public interface UserDao {
    @Query("SELECT * FROM user")
    public abstract LivePagedListProvider<Integer, User> getAllPagination();
}

How to resolve this issue i have setup everything correct as per the sample documentation

Most helpful comment

PagingSource was added in Room 2.3.0-alpha01+

All 11 comments

Hello! Could you share all code?

I resolved the issue by updating the libraries to the latest version

    compile 'android.arch.persistence.room:runtime:1.0.0-beta2'
    annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-beta2'
    compile 'android.arch.paging:runtime:1.0.0-alpha3'

    compile 'android.arch.lifecycle:runtime:1.0.0-beta2'
    compile 'android.arch.lifecycle:extensions:1.0.0-beta2'
    annotationProcessor 'android.arch.lifecycle:compiler:1.0.0-beta2'

I am using androidx room lib and it is up to date. Still I am facing same issue.

implementation 'androidx.room:room-runtime:2.1.0'

i have the same problem with paging 3

@liodali what room version are you using? Try using the latest one at the moment - 2.3.0-alpha02

i'm using version 2.2.5 for room and paging 3 alpha
the build failed message : Not sure how to convert a Cursor to this method's return type androidx.paging.PagingSource

PagingSource was added in Room 2.3.0-alpha01+

Check whether you are not trying to insert a list of objects into your DB, you will need to either embed, use a foreign key or declare the relationship in another table

This is a full list of dependencies that helped me:

def roomVersion = "2.3.0-alpha03"
    implementation "androidx.room:room-runtime:$roomVersion"
    kapt "androidx.room:room-runtime:$roomVersion"
    kapt "androidx.room:room-compiler:$roomVersion"

especially the part with

kapt "androidx.room:room-compiler:$roomVersion"
Was this page helpful?
0 / 5 - 0 ratings