Unable To Resolve Glideapp In Glide 4.1.1
After Going Through tons of forums about same issue, I still not been able to resolve the GlideApp error. It says it cannot be resolved. Here is the screenshot: Here is the java c
Solution 1:
Try with
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'@GlideModule
public class FlickrGlideModule extends AppGlideModule {
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
super.applyOptions(context, builder);
builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888));
}
@OverridepublicvoidregisterComponents(@NonNull Context context, @NonNull Glide glide,
@NonNull Registry registry) {
registry.append(Photo.class, InputStream.class, new FlickrModelLoader.Factory());
}
// Disable manifest parsing to avoid adding similar modules twice.
@OverridepublicbooleanisManifestParsingEnabled() {
returnfalse;
}
}
Read AppGlideModule
FYI
Your loadImage method will be
public static void loadImage(Context ctx,RequestOptions glideRequests, String url, ImageView imageView) {
loadImage(ctx,glideRequests, url, imageView, DiskCacheStrategy.ALL);
}
public static void loadImage(Context ctx,RequestOptions glideRequests, String url, ImageView imageView, DiskCacheStrategy diskCacheStrategy) {
Glide.with(ctx)
.applyDefaultRequestOptions(requestOptions.placeholder(R.drawable.ic_stub).error(R.drawable.ic_stub))
.asBitmap()
.load(url).into(imageView);
}
Then
ImageUtil.loadImage(context,options,obj.getPhotoUrl(),avatarImageView);
Solution 2:
Try this
Import Glide by adding this in gradle
compile'com.github.bumptech.glide:glide:3.8.0'Then use this code
Glide.with(context)
.load(url)
.placeholder(R.drawable.ic_male)
.error(R.drawable.imagenotfound)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
publicboolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
// log exception
Log.e("TAG", handle errorcase", e);
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
Log.e("TAG", handle success case here", e);
returnfalse;
}
})
.into(avatarImageView);
Solution 3:
Seems like great discussion going on. Don't worry. I have solution.
Follow the steps:
Add dependency as follow (I used latest version)
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'Create package (as I always used structured code) myglide and copy/paste following class:
@GlideModule
public class SampleGlideModule extends AppGlideModule {
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
super.applyOptions(context, builder);
}
}
Now you can press CTRL+F9 OR you can click on Make Project option in Build menu.
It will generate one file automatically (You can see by pressing CTRL and hover on ClassName in File.)
finalclassGeneratedAppGlideModuleImplextendsGeneratedAppGlideModule {
privatefinal SampleGlideModule appGlideModule;
....
}
Now you can use GlideApp class very easily.
Feel free to contact me if you get any error.
Hope it will helps you. I love Glide as always. <3
Post a Comment for "Unable To Resolve Glideapp In Glide 4.1.1"