I'm a new to this and I have a project for my thesis, but I have some problems. I always get this error when I run my project, because of that my app always force close.
Attempt to invoke virtual method 'java.lang.Long com.google.firebase.firestore.QueryDocumentSnapshot.getLong(java.lang.String)' on a null object reference.
I don't know where the problem is, or maybe I wrote the wrong code.
public static void loadHome(MyCompleteListener completeListener){
    g_homeList.clear();
    g_firestore.collection("kuis").get()
            .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
                @Override
                public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                    Map<String, QueryDocumentSnapshot> docList = new ArrayMap<>();
                    for (QueryDocumentSnapshot doc : queryDocumentSnapshots){
                        docList.put(doc.getId(), doc);
                    }
                    QueryDocumentSnapshot homeListDoc = docList.get("jml_kuis");
                    long homeCount = homeListDoc.getLong("count");
                    for( int i=1; i <= homeCount; i++){
                        String docID = homeListDoc.getString("kuis" + String.valueOf(i) + "_id");
                        QueryDocumentSnapshot homeDoc = docList.get(docID);
                        int numOfTest = homeDoc.getLong("no_kuis").intValue();
                        String homeName = homeDoc.getString("name");
                        g_homeList.add(new HomeViewModel(docID, homeName, numOfTest));
                    }
                    completeListener.OnSuccess();
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    completeListener.OnFailure();
                }
            });
}
 
     
    