Glide - Cannot resolve method override

Viewed 5812

i am having trouble with Glide from past 2 days. It was working fine but when the update came for Glide depandency it gives me error in my previous code.

here is my code:

  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 and .placeholder is not identifying by Glide.

My Gradle file:

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

Yes i know this is old version, but i even tried with latest version which is...

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

I don't know where i am doing wrong. Please help me out. Thanks

Update 1: I update Glide to latest depandency and then modified my code which is provided by @Ratilal and it looks like this now:

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

So now the error is gone, but i get run time 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)
2 Answers

In 4.3.1 you can use like this.

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

Use latest version with RequestOptions .

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

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

Kindly follow Migrating from v3 to v4 .

Related