I've gone through all the previously asked questions on this topic. But the solutions mentioned aren't working out for me.
As prescribed in the Glide readme, I've registered a model loader for my app, it resides in the app->src->java directory:
MyAppGlideModule.java:
package com.kenadams.app;
import android.content.Context;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
import com.firebase.ui.storage.images.FirebaseImageLoader;
import com.google.firebase.storage.StorageReference;
import java.io.InputStream;
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
// Register FirebaseImageLoader to handle StorageReference
registry.append(StorageReference.class, InputStream.class,
new FirebaseImageLoader.Factory());
}
}
This is how I'm calling the Glide module in my adapter class:
adapter.java
@Override
public void onBindViewHolder(topicAdapter.ViewHolder holder, int position) {
//Setting text
holder.textView.setText(HtmlCompat.fromHtml(this.data.get(position),HtmlCompat.FROM_HTML_MODE_LEGACY));
//Setting image
Glide.with(holder.iv.getContext()).load(sr.child("/1.png")).into(holder.iv);
}
There are no syntax errors and the app is compiling successfully, yet I keep getting this runtime error:
com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders registered for model class: class com.google.firebase.storage.StorageReference
at com.bumptech.glide.load.model.ModelLoaderRegistry.getModelLoaders(ModelLoaderRegistry.java:77)
at com.bumptech.glide.Registry.getModelLoaders(Registry.java:594)
at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:212)
at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:229)
at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:47)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:277)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)
at java.lang.Thread.run(Thread.java:764)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:372)
Some answers have previously mentioned to use GlideApp instead of Glide.However, this doesn't work for me.
I keep getting the syntax error:
Cannot resolve symbol 'GlideApp'
Further when I try to build the module , the build keeps failing due android-exported:true not being in the intent filter. This doesn't make sense as MyAppGlideModule extends AppGlideModule and not AppCompatActivity. So, even if I wanted to add an intent filter with android-exported:true I'd be unable to do so.
What dependencies are you using?
Make sure you have this is added for Kotlin:
kapt 'com.github.bumptech.glide:compiler:4.14.2'
or this for Java:
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
Your finished Glide code should look something like this:
Glide.with(this).load(FirebaseStorageUtil.pathToReference(user.profilePicturePath))
.placeholder(R.drawable.ic_baseline_account_circle_24)
.into(binding.profilePictureImageView)
What dependencies are you using?
Make sure you have this added for Kotlin:
kapt 'com.github.bumptech.glide:compiler:4.14.2'
or this for Java:
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With