【发布时间】:2019-07-30 08:27:02
【问题描述】:
我在过去 2 天内遇到了 Glide 问题。它工作正常,但是当 Glide 依赖的更新到来时,它在我之前的代码中给了我错误。
这是我的代码:
private void showImage(Uri uri, int dimenInPx) {
Glide.with(context)
.load(uri)
.override(dimenInPx, dimenInPx)
.transform(new CircleTransform(context))
.placeholder(R.mipmap.ic_display_pic)
.into((ImageView) findViewById(R.id.img_displayPic));
}
.override、.transform 和 .placeholder 不能被 Glide 识别。
我的 Gradle 文件:
compile 'com.github.bumptech.glide:glide:3.7.0'
是的,我知道这是旧版本,但我什至尝试使用最新版本...
compile 'com.github.bumptech.glide:glide:4.3.1'
我不知道我在哪里做错了。请帮帮我。谢谢
更新 1: 我将 Glide 更新为最新的依赖关系,然后修改了@Ratilal 提供的代码,现在看起来像这样:
Glide.with(context)
.load(uri)
.apply(new RequestOptions()
.override(dimenInPx, dimenInPx)
.placeholder(R.mipmap.ic_display_pic)
.transform(new CircleTransform(context)))
.into((ImageView) findViewById(R.id.img_displayPic));
所以现在错误消失了,但我得到了运行时 NoSuchMethodError。
No virtual method load(Landroid/net/Uri;)Lcom/bumptech/glide/DrawableTypeRequest; in class Lcom/bumptech/glide/RequestManager; or its super classes (declaration of 'com.bumptech.glide.RequestManager' appears in /data/app/com.scoratech.scoraxchange-1/split_lib_dependencies_apk.apk)
【问题讨论】:
-
发布完整的 gradle 文件..
-
就我而言,它正在使用 compile 'com.github.bumptech.glide:glide:3.7.0'
-
@RatilalChopda,是的,正在检查。
标签: android android-glide