I’m using Firebase Realtime Database and Cloud Storage on my Android Things device. I have a rules defined as “allowed to read / write for everyone”. When I’m trying to write something there
final DatabaseReference log = mDatabase.getReference("logs").push();
final StorageReference imageRef = mStorage.getReference().child(log.getKey());
UploadTask task = imageRef.putBytes(imageBytes);
task.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Uri downloadUrl = taskSnapshot.getDownloadUrl();
log.child("timestamp").setValue(ServerValue.TIMESTAMP);
log.child("image").setValue(downloadUrl.toString());
annotateImage(log, imageBytes);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
log.removeValue();
}
});
and I get Firebase error saying that I should sign In first.
Then I tried to sign In (previously created the user)
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// do my work
} else {
// handle error
}
}
});
But now it says:
com.google.firebase.FirebaseNetworkException: A network error (such as timeout, interrupted connection or unreachable host)
I have an internet on a device and it looks like it has the access to the firebase before saying that I need to sign in.
I’m using firebase core, storage, auth and database version of 16.
Any ideas how to solve this issue?
B/c my wi-fi name contains space in it my AndroidThings
device didn’t won’t to connect to it (In a time of installation it said “connection is successful” but it wasn’t. The device saw only first word in the wi-fi name before the space.) So I created a hotspot without the spaces in it and it worked.