Glide showing error: Failed to find GeneratedAppGlideModule
Finally, I found my answer here.
What I have done :
Step-1
I created an empty class named GlideApp
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
@GlideModule
public class GlideApp extends AppGlideModule {
}
Note: Don't forget to add annotation @GlideModule
.
Step-2
After that, I build/rebuild the project and then, replaced Glide
with GlideApp
.and now no need to use RequestOptions
.
public class CustomBindingAdapter {
@BindingAdapter({"bind:image_url"})
public static void loadImage(ImageView imageView, String url) {
// RequestOptions requestOptions = new RequestOptions();
// requestOptions=requestOptions.placeholder(R.drawable.boy_32);
GlideApp.with(imageView.getContext())
.load(url)
.placeholder(R.drawable.boy_32)
.into(imageView);
// Glide.with(imageView.getContext())
// .load(url)
// .apply(requestOptions)
// .into(imageView);
}
}
Edit: For androidx and Glide versin 4.9.0:
In my app's gradle.build:
implementation ("com.github.bumptech.glide:glide:4.9.0") {
exclude group: "com.android.support"
}
annotationProcessor 'androidx.annotation:annotation:1.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation ("com.github.bumptech.glide:glide:4.9.0@aar") {
transitive = true
}
In my gradle.properties:
android.enableJetifier=true
android.useAndroidX=true
That's all.
Kotlin Solution:
Make sure you are adding the following in your gradle file (replace annotationProcessor with kapt source ):
repositories {
mavenCentral()
google()
}
dependencies {
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'
}
Add **AppGlideModule** implementation in your application [GlideSource][2] (You may override the default methods [overrideSource][3]):
import android.content.Context
import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.module.AppGlideModule
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.signature.ObjectKey
@GlideModule
class AppNameGlideModule : AppGlideModule() {
override fun applyOptions(context: Context, builder: GlideBuilder) {
super.applyOptions(context, builder)
builder.apply { RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL) }
}
}
While using glide, use **GlideApp** instead of **Glide**, example:
GlideApp.with(context)
.load(url)
.into(imageView)