0

I updated the firestore version in my application to the latest one and I do not quite understand some changes.

I should convert QueryListenOptions to other methods.

Could someone tell me what it should look like now?

Currently, I get an error: NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/firestore/QueryListenOptions

        Query query = dailyGoalsRef.orderBy("date", Query.Direction.ASCENDING);
    FirestoreRecyclerOptions<DailyGoalsModel> firestoreRecyclerOptions = new FirestoreRecyclerOptions.Builder<DailyGoalsModel>()
            .setQuery(query, DailyGoalsModel.class)
            .build();

    firestoreRecyclerAdapter =
            new FirestoreRecyclerAdapter<DailyGoalsModel, DailyGoalsHolder>(firestoreRecyclerOptions) {
                @Override
                protected void onBindViewHolder(@NonNull DailyGoalsHolder holder, int position, @NonNull DailyGoalsModel model) {
                    String fragmentName = "dailyGoals";
                    holder.setGoalsList(context, userEmail, model, fragmentName);
                }

                @Override
                public DailyGoalsHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.daily_goals_list, parent, false);
                    return new DailyGoalsHolder(view);
                }

                @Override
                public int getItemCount() {
                    return super.getItemCount();
                }
            };

    recyclerView.setAdapter(firestoreRecyclerAdapter);

App:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    //Firebase
    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-firestore:17.1.3'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'

    //Firebase_ui
    implementation 'com.firebaseui:firebase-ui-auth:3.1.3'
    implementation 'com.firebaseui:firebase-ui-firestore:3.1.3'

    //Google Play Services
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.android.gms:play-services-identity:16.0.0'
    implementation 'com.google.android.gms:play-services-plus:16.0.0'

    implementation 'com.android.support:multidex:1.0.3'

Project:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.0.1'
Kamil
  • 113
  • 1
  • 10
  • Try rebuilding the application – Sairaj Sawant Dec 02 '18 at 18:40
  • :app:transformClassesWithDexBuilderForDebug AGPBI: {"kind":"error","text":"Cannot fit requested classes in a single dex file (# methods: 88156 \u003e 65536)","sources":[{}],"tool":"D8"} :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. – Kamil Dec 02 '18 at 19:08
  • Try [this](https://stackoverflow.com/questions/51341627/android-gives-error-cannot-fit-requested-classes-in-a-single-dex-file?noredirect=1&lq=1) – Sairaj Sawant Dec 02 '18 at 19:13
  • I did it for this time. The project was built. I have a main problem back: NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/firestore/QueryListenOptions; – Kamil Dec 02 '18 at 19:19
  • Can u edit your question with dependencies – Sairaj Sawant Dec 02 '18 at 19:22
  • ofc, it's done. – Kamil Dec 02 '18 at 19:30
  • 1
    Try updating the [firebase UI](https://github.com/firebase/FirebaseUI-Android/releases) version to 4.2.1 and rebuild. – Sairaj Sawant Dec 02 '18 at 19:39
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/184590/discussion-between-sai-raj-and-kamil). – Sairaj Sawant Dec 02 '18 at 19:44
  • I did not know about the existence of newer UI versions, because Android Studio did not show them to me. Thank you very much! – Kamil Dec 02 '18 at 19:56

1 Answers1

1

Updating the firebase UI version to 4.2.1 in app-level dependencies and rebuilding should fix your problem.

implementation 'com.firebaseui:firebase-ui-auth:4.1.2'
implementation 'com.firebaseui:firebase-ui-firestore:4.1.2'

Hope that helps !

Sairaj Sawant
  • 1,842
  • 1
  • 12
  • 16