Glide-4.0.0 Missing placeholder, error, GlideApp and does not resolve its method placeholder,error

Try using RequestOptions:

RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.drawable.ic_placeholder);
requestOptions.error(R.drawable.ic_error);

Glide.with(context)
     .setDefaultRequestOptions(requestOptions)
     .load(url).into(holder.imageView);

EDIT

If .setDefaultRequestOptions(requestOptions) does not work, use .apply(requestOptions):

Glide.with(MainActivity.this)
            .load(url)
            .apply(requestOptions)
            .into(imageview);
 // or this
 Glide.with(MainActivity.this)
            .load(url)
            .apply(new RequestOptions().placeholder(R.drawable.booked_circle).error(R.drawable.booked_circle))
            .into(imageview);

 // or this
 Glide.with(MainActivity.this)
            .load(url)
            .apply(RequestOptions.placeholderOf(R.drawable.booked_circle).error(R.drawable.))
            .into(imageview);

EDIT 2 Bonus

Here are some other changes in Glide-4

  • How to use requestOptions.circleCropTransform();
  • How to use Cross fades()
  • How to use GlideDrawableImageViewTarget in Glide-4
  • How to use GifDrawable as target parameter

If you use Glide package dependencies, compile 'com.github.bumptech.glide:glide:3.7.0', then use should be to use the below code:

GlideApp
    .with(your context)
    .load(url)
    .centerCrop()
    .placeholder(R.drawable.loading_image)
    .error(R.drawable.error_image)
    .into(myImageView);

Note: As in the documentation,

Round Pictures: CircleImageView/CircularImageView/RoundedImageView are known to have issues with TransitionDrawable (.crossFade() with .thumbnail() or .placeholder()) and animated GIFs, use a BitmapTransformation (.circleCrop() will be available in v4) or .dontAnimate() to fix the issue.

The latest updated version compile com.github.bumptech.glide:glide:4.1.1 then use should be to use the below code:

RequestOptions options = new RequestOptions()
                    .centerCrop()
                    .placeholder(R.drawable.default_avatar)
                    .error(R.drawable.default_avatar)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .priority(Priority.HIGH)
                    .dontAnimate()
                    .dontTransform();

Glide.with(this)
     .load(url)
     .apply(options)
     .into(imageView);

See the latest version of glide, bug fixes and features.


If you want to use GlideApp you have to add to dependencies annotation processor like on the screenshot:

How to add GlideApp to your project

Then include an AppGlideModule implementation in your application:

@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}

Do not forget about the @GlideModule annotation. Then you need to Build project. And GlideApp will be automatically generated.