无法在Glide 4.1.1中解析GlideApp [英] Unable to Resolve GlideApp in Glide 4.1.1

查看:265
本文介绍了无法在Glide 4.1.1中解析GlideApp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经历了很多关于同一问题的论坛后,我仍然无法解决错误.它说无法解决.这是屏幕截图:

这是Java类,可以使用上面的详细信息

我的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时,它说错误

但是仍然不能解决问题.

解决方案

尝试使用

  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));
  }

  @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);

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 class to use details from above

My build.gradle file already contains:

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

Both and also I have class with below code:

import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;

@GlideModule
public final class CustomAppGlideModule extends AppGlideModule {
}

And I'm using this to to request for:

When I use Glide.with Then it Error says

But still it doesn't solve the problem.

解决方案

Try with

  implementation 'com.github.bumptech.glide:glide:4.8.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'

DEMO

@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));
  }

  @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;
  }
}

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);

这篇关于无法在Glide 4.1.1中解析GlideApp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆