firestoreRecyclerAdapter无虚拟方法getDocument



我当前正在将firebase UI组件转换为firestore UI组件。构建FirestoreRecyclerAdapter并手动致电adapter.startListening()或通过new FirestoreRecyclerOptions.Builder().setLifeCycleOwner()初始化它时,我偶然发现了以下致命例外。

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)

错误指出类DocumentSnapshot不包含方法getDocument,该方法在检查后正确。但是,这也是Firebaseui在其文档中陈述该实现的方式,我无法弄清楚我在哪里做错了什么。

用于回收器的查询 Query query = mFirestore.collection("spots");,该集合存在,并在内部具有documents

带有查询的适配器

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依赖关系

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'

适配器正在以片段的onCreateView方法初始化。我遵循Firebaseui的GitHub页面上的说明,但没有成功(link(

请尽量不要双重发帖。

对于其他所有人:这是一个已知的问题,将在FUI 3.3.0与Play Services 12.0.1配对。目前,降级到播放服务11.8.0将做到这一点。

相关内容

  • 没有找到相关文章

最新更新