0

I'm trying to load image from Firebase storage, but getting exception while using Glide

My Code

storageReference=FirebaseStorage.getInstance().getReference().child("profiles/"+firebaseUser.getUid()+"/"+"profilePic");
            Glide.with(FinishIntroActivity.this)
                    .load(storageReference.getDownloadUrl())
                    .into(profileFinishImg);

My Gradle

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

Exception i am getting

W/Glide: Load failed for com.google.android.gms.tasks.zzu@669eaa8 with size [525x525]
    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
    There was 1 cause:
    com.bumptech.glide.Registry$NoModelLoaderAvailableException(Failed to find any ModelLoaders for model: com.google.android.gms.tasks.zzu@669eaa8)
     call GlideException#logRootCauses(String) for more detail
      Cause (1 of 1): class com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: com.google.android.gms.tasks.zzu@669eaa8
2020-05-02 11:32:07.951 8343-8343/com.happyorbit.happyorbit I/Glide: Root cause (1 of 1)
    com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: com.google.android.gms.tasks.zzu@669eaa8
        at com.bumptech.glide.Registry.getModelLoaders(Registry.java:584)
        at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:205)
        at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:223)
        at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:44)
        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)
        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:269)
        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)

Please help me to use Glide without error. Thanks

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441

1 Answers1

0

As you can see from the documentation, getDownloadUrl() doesn't acutally return a URL. It asynchronously returns a Task that will give you the URL if you add a listener to it. You will only get that URL after it's delivered to the listener, and you don't have a guarantee when that will complete.

I suggest reading the answer to this other question for more details and examples: How to get URL from Firebase Storage getDownloadURL

Another alternative is to use FirebaseUI Storage as a plugin for Glide that will do most of the hard work for you.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441