I am making a user profile fragment for my application and I have been getting an error in my imageUri
private fun uploadProfilePicture(){
imageUri = Uri.parse("android.resource://$packageName/${R.drawable.placeholderprofile}")
storageReference = FirebaseStorage.getInstance().getReference("Users/" auth.currentUser?.uid)
storageReference.putFile(imageUri).addOnSuccessListener {
Toast.makeText(activity, "Save successful", Toast.LENGTH_SHORT).show()
}.addOnFailureListener{
Toast.makeText(activity, "Upload image failed", Toast.LENGTH_SHORT).show()
}
}
Why does it not recognize $packageName?
I have tried rebuilding and cleaning, gradle sync, and invalidating caches.
CodePudding user response:
Can you try this? activity?.packageName
instead? so it will become ${activity?.packageName}
imageUri = Uri.parse("android.resource://${activity?.packageName}/${R.drawable.placeholderprofile}")