Я использую Kotlin для программирования. Когда я добавляю документ, используя
collectionRef
.add(settlement) // Adds Auto-ID
.addOnSuccessListener({ documentReference ->
Log.d("Add Doc", "DocumentSnapshot written with ID: " + documentReference.id)
})
.addOnFailureListener({ e ->
Log.w("Add Doc Failed", "Error adding document", e)
})
.addOnCompleteListener({ task ->
if (task.getException() != null) {
Log.w("Add Doc Failed", "Error adding document", task.getException())
}
if (task.isComplete()) { //try task.isSuccessful() if this is what you are looking for
Log.w("Add Doc Failed", "Error adding document")
}
})
Всегда выдает исключение, которое addOnFailureListener не перехватывает вообще:
05-06 14:14:18.091 28113-28126/com.plabs.settle E/StorageHelpers: Failed to turn object into JSON
java.lang.NullPointerException: Attempt to invoke virtual method 'org.json.JSONObject com.google.firebase.auth.internal.zzm.zzbf()' on a null object reference
at com.google.firebase.auth.internal.zzz.zzi(Unknown Source:116)
at com.google.firebase.auth.internal.zzz.zzg(Unknown Source:3)
at com.google.firebase.auth.FirebaseAuth.zza(Unknown Source:92)
at com.google.firebase.auth.zzm.zza(Unknown Source:3)
at com.google.firebase.auth.api.internal.zzaw.zzaa(Unknown Source:27)
at com.google.firebase.auth.api.internal.zzcy.zzal(Unknown Source:0)
at com.google.firebase.auth.api.internal.zzcy.zza(Unknown Source:0)
at com.google.firebase.auth.api.internal.zzdb.zzb(Unknown Source:41)
at com.google.firebase.auth.api.internal.zzci.dispatchTransaction(Unknown Source:139)
at com.google.android.gms.internal.firebase_auth.zzb.onTransact(Unknown Source:22)
at android.os.Binder.execTransact(Binder.java:726)
05-06 14:14:18.101 28113-28126/com.plabs.settle W/Binder: Caught a RuntimeException from the binder stub implementation.
com.google.android.gms.internal.firebase_auth.zzv: java.lang.NullPointerException: Attempt to invoke virtual method 'org.json.JSONObject com.google.firebase.auth.internal.zzm.zzbf()' on a null object reference
at com.google.firebase.auth.internal.zzz.zzi(Unknown Source:140)
at com.google.firebase.auth.internal.zzz.zzg(Unknown Source:3)
at com.google.firebase.auth.FirebaseAuth.zza(Unknown Source:92)
at com.google.firebase.auth.zzm.zza(Unknown Source:3)
at com.google.firebase.auth.api.internal.zzaw.zzaa(Unknown Source:27)
at com.google.firebase.auth.api.internal.zzcy.zzal(Unknown Source:0)
at com.google.firebase.auth.api.internal.zzcy.zza(Unknown Source:0)
at com.google.firebase.auth.api.internal.zzdb.zzb(Unknown Source:41)
at com.google.firebase.auth.api.internal.zzci.dispatchTransaction(Unknown Source:139)
at com.google.android.gms.internal.firebase_auth.zzb.onTransact(Unknown Source:22)
at android.os.Binder.execTransact(Binder.java:726)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'org.json.JSONObject com.google.firebase.auth.internal.zzm.zzbf()' on a null object reference
at com.google.firebase.auth.internal.zzz.zzi(Unknown Source:116)
at com.google.firebase.auth.internal.zzz.zzg(Unknown Source:3)
at com.google.firebase.auth.FirebaseAuth.zza(Unknown Source:92)
at com.google.firebase.auth.zzm.zza(Unknown Source:3)
at com.google.firebase.auth.api.internal.zzaw.zzaa(Unknown Source:27)
at com.google.firebase.auth.api.internal.zzcy.zzal(Unknown Source:0)
at com.google.firebase.auth.api.internal.zzcy.zza(Unknown Source:0)
at com.google.firebase.auth.api.internal.zzdb.zzb(Unknown Source:41)
at com.google.firebase.auth.api.internal.zzci.dispatchTransaction(Unknown Source:139)
at com.google.android.gms.internal.firebase_auth.zzb.onTransact(Unknown Source:22)
at android.os.Binder.execTransact(Binder.java:726)
Что я делаю не так, когда я вызываю collectionRef.get (), я получаю все записи, добавленные до сих пор, но ни одна не показывается через консоль Firestore.
Помогите мне решить эту проблему.