Using Firebase Storage image with Glide
Change this:
implementation 'com.firebaseui:firebase-ui-storage:2.0.1'
to this:
implementation 'com.firebaseui:firebase-ui-storage:3.2.1'
According to the Glide docs:
using()
The using() API was removed in Glide 4 to encourage users to register their components once with a AppGlideModule to avoid object re-use. Rather than creating a new ModelLoader each time you load an image, you register it once in an AppGlideModule and let Glide inspect your model (the object you pass to load()) to figure out when to use your registered ModelLoader.
To make sure you only use your ModelLoader for certain models, implement handles() as shown above to inspect each model and return true only if your ModelLoader should be used.
using()
was removed from Glide 4.
To Solve this, you need to do this: To load an image from a StorageReference, first register an AppGlideModule:
@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());
}
}
Once you have created an AppGlideModule class and done a clean build, you can use GlideApp to load a StorageReference into an ImageView:
// Reference to an image file in Cloud Storage
StorageReference storageReference = ...;
// ImageView in your Activity
ImageView imageView = ...;
// Download directly from StorageReference using Glide
// (See MyAppGlideModule for Loader registration)
GlideApp.with(this /* context */)
.load(storageReference)
.into(imageView);
more info here: https://github.com/firebase/FirebaseUI-Android/tree/master/storage
I Know im bit late but it might help some of you.
Use both of these in app build.gradle
.
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0' //For Kotlin You should use kapt instead of annotationProcessor though.
Then add This Class:
@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());
}
}
GlideApp.with(getActivity()).load(storageReference).into(profileImg);
At last you need to go to File-> Invalidate Cache and Restart Done:)