I am using firebase storage to upload files , but when I upload I am getting this error
E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.android.gms.internal.zzand: Please sign in before trying to get a token.
I googled it but couldn't get answer for it! I have signed in, in firebase.
I think you didn't sign before uploading files. In onCreate() of launcher activity, try this code
FirebaseAuth mAuth = FirebaseAuth.getInstance();
Then in onStart(),
FirebaseUser user = mAuth.getCurrentUser();
if (user != null) {
// do your stuff
} else {
signInAnonymously();
}
signInAnonymously()
private void signInAnonymously() {
mAuth.signInAnonymously().addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
// do your stuff
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Log.e(TAG, "signInAnonymously:FAILURE", exception);
}
});
}
This may solve your problem