title: Paging3: "Not sure how to convert a Cursor to this method's return type" when using PagingSource as return type in Room DAO
body: <p>I was trying to imitate Google's codelab for the new Paging 3 library, and I encountered the following error when I tried to have a Room DAO method return a <code>PagingSource</code>:</p>
  <pre><code>D:\Programming\Android\something\app\build\tmp\kapt3\stubs\debug\com\someapp\something\data\db\UsersDao.java:38: error: Not sure how to convert a Cursor to this method's return type (androidx.paging.PagingSource&lt;java.lang.Integer,com.someapp.something.data.db.GithubUser&gt;).
      public abstract androidx.paging.PagingSource&lt;java.lang.Integer, com.someapp.something.data.db.GithubUser&gt; getUserByUserName(@org.jetbrains.annotations.NotNull()
      
  ^D:\Programming\Android\something\app\build\tmp\kapt3\stubs\debug\com\someapp\something\data\db\UsersDao.java:43: error: Not sure how to convert a Cursor to this method's return type (androidx.paging.PagingSource&lt;java.lang.Integer,com.someapp.something.data.db.GithubUser&gt;).
  public abstract androidx.paging.PagingSource&lt;java.lang.Integer, com.someapp.something.data.db.GithubUser&gt; getUserByNote(@org.jetbrains.annotations.NotNull()
  </code></pre>
  <p>Here is my <code>UsersDao.kt</code>:</p>
  <pre><code>@Dao
  interface UsersDao {
  
      @Insert
      fun insert(user: GithubUser): Completable
  
      @Insert
      fun insert(userList: List&lt;GithubUser&gt;): Completable
  
      @Query(&quot;DELETE FROM userDb&quot;)
      fun clearDb(): Completable
  
      @Query(&quot;SELECT * FROM userDb&quot;)
      fun getAllUsers(): Single&lt;List&lt;GithubUser&gt;&gt;
  
      @Query(&quot;SELECT EXISTS(SELECT 1 FROM userDb WHERE username LIKE :userName)&quot;)
      fun checkIfUserExists(userName: String): Boolean
  
      @Query(&quot;SELECT note FROM userDb WHERE username LIKE :userName&quot;)
      fun getNoteByUserName(userName: String): Single&lt;String&gt;
  
      @Query(&quot;SELECT * FROM userDb WHERE username LIKE :userName&quot;)
      fun getUserByUserName(userName: String): PagingSource&lt;Int, GithubUser&gt;
  
      @Query(&quot;SELECT * FROM userDb WHERE note LIKE :note&quot;)
      fun getUserByNote(note: String): PagingSource&lt;Int, GithubUser&gt;
  
  }
  </code></pre>
  <p>My <code>GithubUser.kt</code> looks like this:</p>
  <pre><code>@Entity(tableName = &quot;userDb&quot;, indices = arrayOf(Index(value = [&quot;username&quot;],  unique = true)))
  class GithubUser (
      var username: String,
      var note: String,
      var url: String,
      var avatarUrl: String
  ) {
      @PrimaryKey(autoGenerate = true)
      var uid = 0
  }
  </code></pre>
  <p>In the <a href="https://github.com/googlecodelabs/android-paging/blob/step13-19_network_and_database/app/src/main/java/com/example/android/codelabs/paging/db/RepoDao.kt" rel="noreferrer">code</a> for the Paging Codelab, the DAO method just returns a <code>PagingSource</code> with no extra annotations/magic options in Gradle or whatever. I also looked at other examples from Github like <a href="https://github.com/ThomasWilliamMarsh/Gif-Finder-Android/blob/0f634daa16abbc89ba6666238bcdeed34c23333b/core/src/main/java/info/tommarsh/giffinder/core/gifs/repository/datasource/local/GifsDao.kt" rel="noreferrer">this</a> and <a href="https://github.com/chaytanyasinha/Brewery-Database-App/blob/master/app/src/main/java/com/kevalpatel2106/brew/repo/db/BreweryDao.kt" rel="noreferrer">this</a> that use the Paging 3 library, they just return <code>PagingSource</code> with no problems at all. Can anyone tell me if I missed something?</p>
  <p><strong>NOTE</strong>: Before the error itself, I always get a warning about <code>ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1</code>, but this warning itself has not caused any problems in the past, but I am noting it here just in case.</p>
  <p><strong>EDIT</strong>: I use the following Room/Paging lib versions:</p>
  <pre><code>    implementation &quot;androidx.room:room-runtime:2.2.5&quot;
      kapt &quot;androidx.room:room-compiler:2.2.5&quot;
      implementation 'androidx.room:room-rxjava2:2.2.5'
  
      implementation &quot;androidx.paging:paging-runtime:3.0.0-alpha03&quot;
      implementation 'androidx.paging:paging-rxjava2:3.0.0-alpha03'
  </code></pre>