Reputation: 833
I am currently converting my Firebase UI components to Firestore UI components. When building the FirestoreRecyclerAdapter
and manually call the adapter.startListening()
or initialize it via new FirestoreRecyclerOptions.Builder().setLifeCycleOwner()
I stumble on the following fatal exception.
FATAL EXCEPTION: main
Process: packagename, PID: 3129
java.lang.NoSuchMethodError: No virtual method getDocument()Lcom/google/firebase/firestore/DocumentSnapshot; in class Lcom/google/firebase/firestore/DocumentChange; or its super classes (declaration of 'com.google.firebase.firestore.DocumentChange' appears in /data/app/packagename-yHh4aIRPAZwxxRYgunJivQ==/split_lib_dependencies_apk.apk)
at com.firebase.ui.firestore.FirestoreArray.onDocumentAdded(FirestoreArray.java:98)
at com.firebase.ui.firestore.FirestoreArray.onEvent(FirestoreArray.java:83)
at com.firebase.ui.firestore.FirestoreArray.onEvent(FirestoreArray.java:21)
at com.google.firebase.firestore.zzi.onEvent(Unknown Source:17)
at com.google.android.gms.internal.zzeyn.zza(Unknown Source:6)
at com.google.android.gms.internal.zzeyo.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
The error states that the class DocumentSnapshot
doesn't contain a method getDocument
which after checking is correct. However this is also how FirebaseUI states this implementation in their documentation and I can't figure out where I'm doing something wrong.
The query used for the recycler
Query query = mFirestore.collection("spots");
, The collection is present and has documents
within.
The adapter with query
mRecyclerView = (RecyclerView) view;
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
Query query = mFirestore.collection("spots");
FirestoreRecyclerOptions<SpotModel> options = new FirestoreRecyclerOptions.Builder<SpotModel>().setQuery(query, SpotModel.class).setLifecycleOwner(this).build();
mAdapter = new FirestoreRecyclerAdapter<SpotModel, SpotHolder>(options) {
@Override
public SpotHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_spot, parent, false);
return new SpotHolder(view);
}
@Override
protected void onBindViewHolder(@NonNull SpotHolder holder, int position, @NonNull SpotModel model) {
holder.bind(model);
}
};
mRecyclerView.setAdapter(mAdapter);
FirebaseUI dependencies
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
implementation 'com.firebaseui:firebase-ui-firestore:3.2.2'
The adapter is being initialized in the onCreateView
method of a fragment. I followed the instructions on the Github page of FirebaseUI but without success (link)
Upvotes: 0
Views: 371
Reputation: 4007
Please try not to double post.
For everyone else: this is a known issue and will be fixed in FUI 3.3.0 paired with Play Services 12.0.1. For now, downgrading to Play Services 11.8.0 will do the trick.
Upvotes: 1