Captain Jacky
Captain Jacky

Reputation: 1059

Android Glide: Failed to load resource of Firebase Storage

I'm trying to display the image in CircularImageView stored in Firebase Storage, but glide gives me this error:

W/Glide: Load failed for gs://project-2d8i4.appspot.com/pictures/3HnfQSeBladDsD9sPEcKrhxJ6CB2 with size [1200x1200]
    class com.bumptech.glide.load.engine.GlideException: Failed to load resource

The picture is saved in Firestore as:

"gs://project-2d8i4.appspot.com/pictures/3HnfQSeBladDsD9sPEcKrhxJ6CB2"

Binding to image view (uri = "gs://project-2d8i4.appspot.com/pictures/3HnfQSeBladDsD9sPEcKrhxJ6CB2"):

fun CircularImageView.bindProfilePicture(uri: String?) {
    Glide
        .with(this)
        .load(uri)
        .into(this)
}

Dependencies for glide:

implementation 'com.github.bumptech.glide:glide:4.12.0'

No answers in any posts helped me whatsoever. I hope someone could help me. Thanks.

Upvotes: 0

Views: 1109

Answers (2)

Android Killer
Android Killer

Reputation: 18489

To avoid cache as mentioned in comments, you can use these two along with glide call.

diskCacheStrategy(DiskCacheStrategy.NONE) 
.skipMemoryCache(true)

Check here to use the glide to download from firebase url.

Upvotes: 1

Alex Mamo
Alex Mamo

Reputation: 138824

The following URL:

gs://project-2d8i4.appspot.com/pictures/3HnfQSeBladDsD9sPEcKrhxJ6CB

Is indeed a file that is stored in Cloud Storage. Unfortunately, this URL is not recognized by Glide, as it is not a valid URL. To solve the problem you need to get the "download URL" rather than an URL that starts with gs://....

To get the actual download URL, please see the official documentation for:

And my answer from the following post:

Upvotes: 2

Related Questions