CollectionGroup()不是公开.无法从外部包装访问



我想在 RecyclerView.ViewHolder中使用 collectionGroup()在我的 FirebaseFirestore上查询一个子汇编,我会发现一个错误:

'collectiongroup(java.lang.string('不公开 'com.google.firebase.firestore.firebasefirestore'。无法访问 从外部包装

class WallHolder extends RecyclerView.ViewHolder {
        private LinearLayout root, llp, image_layout;
        private RelativeLayout rlp;
        private TextView comment, tv_due, tv_pass;
        private Button btn_play;
        private SeekBar seekBar;
        private ImageView imageView[] = new ImageView[3];
        public WallHolder(@NonNull View itemView) {
            super(itemView);
            root = itemView.findViewById(R.id.list_root);
            llp = root.findViewById(R.id.llp);
            rlp = root.findViewById(R.id.rlp);
            comment = root.findViewById(R.id.tv_cmt);
            image_layout = root.findViewById(R.id.img_layout);
            btn_play = llp.findViewById(R.id.btn_play);
            tv_due = rlp.findViewById(R.id.tv_due);
            tv_pass = rlp.findViewById(R.id.tv_pass);
            seekBar = rlp.findViewById(R.id.seek_bar);
            imageView[0] = image_layout.findViewById(R.id.img_1);
            imageView[1] = image_layout.findViewById(R.id.img_2);
            imageView[2] = image_layout.findViewById(R.id.img_3);
        }

        void setData(final Map<String, Object> post) {
            FirebaseFirestore db = FirebaseFirestore.getInstance();
            final StorageReference storageRef = FirebaseStorage.getInstance().getReference();

            //This is where i get the error
            //db.collectionGroup()
            //

            //This code wasn't working so i want to replace it with the code above
            db.collection("Post")
                    //.document(post.get("post_Id").toString())
                    .document("mnk2EqrVmm3upTFYL4eB")
                    .collection("Post_Images")
                    .get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                        @Override
                        public void onComplete(@NonNull Task<QuerySnapshot> task) {
                            if (task.isSuccessful()) {
                                final List<Bitmap> list = new ArrayList<>();
                                Toast.makeText(WallActivity.this, String.valueOf(task.getResult().size()), Toast.LENGTH_SHORT).show();
                                for (QueryDocumentSnapshot document : task.getResult()){
                                }
                            } else {
                            }
                        }
                    });
        }
    }

您会收到以下错误:

'collectionGroup(java.lang.string('在'com.google.firebase.firestore.firebasefirestore中不公开。无法从外部软件包访问

因为在Firestore的较早版本中,FirebaseFirestore的CollectionGroup(String collectionID(方法是在没有修饰符的情况下定义的,这意味着只能在同一类和同一软件包中访问。

。 。

由于这两个条件都无法满足,因此您可以在班级或软件包之外访问该方法。因此,这意味着您是不是使用最新版本的

从2019年5月8日开始,collectionGroup(String collectionId)已公开,因此请您升级Firestore依赖性:

implementation 'com.google.firebase:firebase-firestore:19.0.0'

您将能够使用该方法。

最新更新