I set an onclicklistner in my update button, where i want to upload image and username in firebasestore(firestore version 22.1.2). I have add all firestore depandency in gradle, getDownloadUrl is not working it says cannot find symbol method getDownloadUrl
String user_id = firebaseAuth.getCurrentUser().getUid();
StorageReference image_path = storageReference.child("profile_image").child(user_id+".jpg");
image_path.putFile(mainImageURI).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if(task.isSuccessful()){
Uri download_uri = task.getResult().getDownloadUrl(); //Have error in this getDownloadUrl().
Map<String,String> userMap = new HashMap<>();
userMap.put("name",user_name);
userMap.put("image",download_uri);
firebaseFirestore.collection("Users").document(user_id).set(userMap).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
finish();
Toast.makeText(SetupActivity.this,"The User Settings are updated ", Toast.LENGTH_LONG).show();
Intent mainIntent = new Intent(SetupActivity.this, MainActivity.class);
startActivity(mainIntent);
}else {
String error = task.getException().getMessage();
Toast.makeText(SetupActivity.this,"Firestore Error: "+error, Toast.LENGTH_LONG).show();
}
setupProgress.setVisibility(View.INVISIBLE);
}
});
}else{
String error = task.getException().getMessage();
Toast.makeText(SetupActivity.this,"Image Error: "+error, Toast.LENGTH_LONG).show();
setupProgress.setVisibility(View.INVISIBLE);
}
}
});