无法在 Glide 4.1.1 中解析 GlideApp

在浏览了大量关于同一问题的论坛后,我仍然无法解决GlideApp错误。它说它无法解决。这是屏幕截图:

http://img.mukewang.com/614194d7000110c507760407.jpg

这是使用上面详细信息的java类

http://img2.mukewang.com/614194e30001a63808250253.jpg

我的build.gradle文件已经包含:


  compile 'com.github.bumptech.glide:glide:4.1.1'

annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'

我和我都有以下代码的课程:


import com.bumptech.glide.annotation.GlideModule;

import com.bumptech.glide.module.AppGlideModule;


@GlideModule

public final class CustomAppGlideModule extends AppGlideModule {

}

我用它来请求:


当我使用Glide.with然后它错误说

http://img1.mukewang.com/614194ee000185bc06330161.jpg

但它仍然没有解决问题。


幕布斯6054654
浏览 262回答 3
3回答

慕娘9325324

试试  implementation 'com.github.bumptech.glide:glide:4.8.0'  annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'演示@GlideModulepublic 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));  }  @Override  public void registerComponents(@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.  @Override  public boolean isManifestParsingEnabled() {    return false;  }}读 AppGlideModule供参考你的loadImage方法将是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);    }然后ImageUtil.loadImage(context,options,obj.getPhotoUrl(),avatarImageView);

慕容森

似乎正在进行很好的讨论。别担心。我有解决方案。按照步骤:添加依赖项如下(我使用的是最新版本)implementation 'com.github.bumptech.glide:glide:4.8.0'annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'创建包(因为我一直使用结构化代码)myglide 并复制/粘贴以下类:@GlideModulepublic class SampleGlideModule extends AppGlideModule {&nbsp; &nbsp; @Override&nbsp; &nbsp; public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {&nbsp; &nbsp; &nbsp; &nbsp; super.applyOptions(context, builder);&nbsp; &nbsp; }}现在您可以按CTRL+F9或您可以单击菜单Make Project中的Build选项。它将自动生成一个文件(您可以通过按 CTRL 并将鼠标悬停在 File 中的 ClassName 上来查看。)final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule {&nbsp; private final SampleGlideModule appGlideModule;&nbsp; ....}现在您可以非常轻松地使用GlideApp类。如果您有任何错误,请随时与我联系。希望它会帮助你。我一如既往地喜欢 Glide。<3

BIG阳

尝试这个进口Glide在增加的gradle这个compile 'com.github.bumptech.glide:glide:3.8.0'然后使用此代码Glide.with(context)&nbsp; &nbsp; &nbsp; &nbsp; .load(url)&nbsp; &nbsp; &nbsp; &nbsp; .placeholder(R.drawable.ic_male)&nbsp; &nbsp; &nbsp; &nbsp; .error(R.drawable.imagenotfound)&nbsp; &nbsp; &nbsp; &nbsp; .listener(new RequestListener<String, GlideDrawable>() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // log exception&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.e("TAG", handle error case", e);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Log.e("TAG", handle success case here", e);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; .into(avatarImageView);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java