Glide - 无法解析方法覆盖

Glide - Cannot resolve method override

过去 2 天我在使用 Glide 时遇到了问题。它工作正常,但是当 Glide depandency 的更新到来时,它给我之前的代码带来了错误。

这是我的代码:

  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 更新到最新的 depandency,然后修改了由 @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)

将最新版本与 RequestOptions 一起使用。

RequestOptions myOptions = new RequestOptions()
    .fitCenter()
    .override(dimenInPx, dimenInPx);

Glide.with(context)
    .load("URL")
    .apply(myOptions)
    .into(ImageView);

欢迎关注Migrating from v3 to v4 .

4.3.1中你可以这样使用。

Glide.with(this)
     .load(YOUR_URL)
     .apply(new RequestOptions().override(dimenInPx, dimenInPx).placeholder(R.drawable.placeHolder).error(R.drawable.error_image))
     .into(imageview);