Why is this error happening? In the debug mode there's no special characters in the key, no '.', only the '/' necessary for the path. It was working well, I just wiped my database and then I run again with the error in the title. My code:
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
String animalUid = animal.getUid();
if (animalUid == null) {
animalUid = databaseReference.push().getKey();
}
Map<String, Object> animalData = new HashMap();
if(animal.getFavorites()!=null) {
for (Map.Entry<String, Boolean> entry : animal.getFavorites().entrySet()) {
animalData.put("users-favorites-animals/" + entry.getKey() + "/" + animalUid, animal);
}
}
animalData.put("users-animals/" + animal.getOwnerUid() + "/" + animalUid, animal);
animalData.put("animals/" + animalUid, animal);
databaseReference.updateChildren(animalData).addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
listener.onSaveAnimalSucess(animal);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
if (e instanceof FirebaseException) {
listener.onSaveAnimalError("");
return;
}
listener.onConnectionError();
}
});
Here how the animalData keys comes before updateChildren:
"animals/-Kcd_8Tif5EPYUhsceeH"
"users-animals/LoQ9Bkjs2yVC95nFGyo1ft4cqdB2/-Kcd_8Tif5EPYUhsceeH"
Even my old code without the multi-data updates is not working, with the same error. I have no idea what's going on.
10.0.x
... Check the latest APIanimalUid
, andanimal.getOwnerUid()
?