CodexBloom - Programming Q&A Platform

how to to access Firebase Storage in Android Studio while using Jetpack Compose - No 'permission denied' scenarios

๐Ÿ‘€ Views: 19 ๐Ÿ’ฌ Answers: 1 ๐Ÿ“… Created: 2025-06-14
android firebase jetpack-compose storage Kotlin

I'm trying to debug I've been banging my head against this for hours. I'm currently developing an Android application using Jetpack Compose and trying to upload images to Firebase Storage. I've set up Firebase in my project and the dependencies are correctly included in my `build.gradle` file. However, when I attempt to upload an image, I'm not receiving any behavior messages, but the upload is failing silently. Hereโ€™s the relevant code snippet where Iโ€™m attempting to upload an image: ```kotlin val storage = FirebaseStorage.getInstance() val storageRef = storage.reference fun uploadImage(imageUri: Uri) { val imageRef = storageRef.child("images/${imageUri.lastPathSegment}") val uploadTask = imageRef.putFile(imageUri) uploadTask.addOnSuccessListener { taskSnapshot -> Log.d("Upload", "Image uploaded successfully: ${taskSnapshot.metadata?.path}") } .addOnFailureListener { exception -> Log.e("Upload", "Failed to upload image: ${exception.message}") } } ``` I have also ensured that my Firebase Storage rules allow read and write operations for testing: ```json service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow read, write: if true; } } } ``` Additionally, I have added the necessary permissions in the `AndroidManifest.xml`: ```xml <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> ``` Yet, Iโ€™m not seeing any logs indicating that the upload task is being triggered. Iโ€™ve confirmed that the `imageUri` is valid and not null by logging it before the upload function call. Iโ€™m testing this on an Android 11 emulator with the latest version of Android Studio (Chipmunk | 2021.2.1) and the Firebase SDK version is 28.3.1. Could this be due to a configuration scenario, or is there something specific to Jetpack Compose that might be affecting the functionality? Any insights or similar experiences would be greatly appreciated. Any help would be greatly appreciated! I'd really appreciate any guidance on this. For context: I'm using Kotlin on Ubuntu 20.04. Could this be a known issue?