0
/*--- Load News Feed in Recycler View ---*/
    private void loadNewsFeed(){


        CollectionReference collectionReference = firebaseFirestore.collection("News Feed");
        query =  collectionReference
            .orderBy("newsFeedId", Query.Direction.DESCENDING);
        

        PagingConfig config = new PagingConfig(1,
                                               1,
                                               false);


        FirestorePagingOptions<ModelNewsFeed> options = new FirestorePagingOptions.Builder<ModelNewsFeed>()
                .setLifecycleOwner(this)
                .setQuery(query, config, ModelNewsFeed.class)
                .build();



        adapterNewsFeedListFireStorePaginationAds = new AdapterNewsFeedListFireStorePaginationAds(options, this);

        newsFeedRv.setAdapter(adapterNewsFeedListFireStorePaginationAds);




    }

I am getting an Error at ".setQuery(query, config, ModelNewsFeed.class)"

Error: .setQuery(query, config, ModelNewsFeed.class)
                ^
    method Builder.setQuery(Query,Config,Class<ModelNewsFeed>) is not applicable
      (argument mismatch; PagingConfig cannot be converted to Config)
    method Builder.setQuery(Query,Config,SnapshotParser<ModelNewsFeed>) is not applicable
      (argument mismatch; PagingConfig cannot be converted to Config)

What's the solution to rectify this error?

I am trying to migrate from

Paging 2: androidx.paging:paging-runtime:2.1.2

to

Paging 3:

androidx.paging:paging-runtime:3.0.1.

Error Screen Shot

Pawan Kumar
  • 211
  • 2
  • 12
  • Have you tried to only call `.setQuery(query, ModelNewsFeed.class)`? Does it work this way? – Alex Mamo Aug 31 '21 at 09:16
  • I have to use pagination. and .setQuery(query, ModelNewsFeed.class) works perfect to load all items at once. I have followed the steps mentioned in https://firebaseopensource.com/projects/firebase/firebaseui-android/firestore/readme/. But for pagination It's giving me an error. – Pawan Kumar Aug 31 '21 at 09:27
  • I have updated the screen shot of Error Message which I'm getting for more clarification. – Pawan Kumar Aug 31 '21 at 09:33
  • How did you import the PagingConfig? Please edit your question and add the corresponding line. – Alex Mamo Aug 31 '21 at 09:35
  • First of all I replaced the dependency in gradle file. Then from https://firebaseopensource.com/projects/firebase/firebaseui-android/firestore/readme/ , I copied the code for PagingConfig. After Pressing Alt+ Enter to import , This is imported in Java File "import androidx.paging.PagingConfig;". Then this error starts coming. If anything else, you want to know, Let me know. – Pawan Kumar Aug 31 '21 at 09:49
  • @AlexMamo Any suggestion to rectify it!!.. Waiting for your response. – Pawan Kumar Aug 31 '21 at 10:50
  • What version of firebase-ui are you using? Make sure you're on 8.0.0 as it seems that's the version the Paging3 bindings were added. Could you share the result of `./gradlew dependencies` or your build file? – dlam Sep 15 '21 at 23:34
  • @dlam Thank You Sir, It worked, latterly It Worked Sir, Thank you so much sir. firebase ui was on version 7.1.1 and After upgrading it to 8.0.0. , It started working. – Pawan Kumar Sep 29 '21 at 13:37

1 Answers1

1

@dlam Has provided me the solution of this under comment section of this thread. My android studio was using Firebase ui version 7.1.1 and it has to be 8.0.0 as mentioned by @dlam. And resolved the issue.

Thank you @dlam. https://stackoverflow.com/users/1452382/dlam

Pawan Kumar
  • 211
  • 2
  • 12