Glide not loading real image and stuck with placeholder

I have a pretty basic load image from server line code:

Glide.with(view.getContext()).load(url).placeholder(R.drawable.default_profile).into(view);

For some reason, I'm always stuck with the placeholder being displayed and never the real image!

I have made sure that a valid and working url is being passed. And, if I use the same code without the placeholder it works fine

Glide.with(view.getContext()).load(url).into(view);

Any ideas why?


Solution 1:

Try to add .dontAnimate() It caused by TransitionDrawable too and it seems so because after scroll there's no animation because it's cached.

The correct code is

Glide.with(view.getContext()).load(url).placeholder(R.drawable.default_profile).dontAnimate().into(view);

I hope it will be helpful for you.

Solution 2:

Check if you have added Internet permission in the manifest:

<uses-permission android:name="android.permission.INTERNET"/>

Glide does not fire exception if there is no Internet connectivity.

Solution 3:

Add android:usesCleartextTraffic="true" in the application tag in manifest and check the internet permission is mentioned or not in the same manifest file:-

Solution 4:

Use ProgressBar as loading gif

Glide.with(context).
        load(url)
        .listener(new RequestListener<String, GlideDrawable>() {
            @Override
            public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                return false;
            }
        })
        .crossFade(1000)
        .into(imageView);