AndroidDev
AndroidDev

Reputation: 21237

Android Glide won't load .jpg from url

I have a glide method that I use all the time to fetch images from a url. It has previously worked without exception. In a new layout, I have an ImageView whose image i need to fetch from a url and display. But when the view renders, the image view is blank.

The strange part is that when I observe the network traffic via Charles, there is no call to fetch the url whatsoever. Not even one that fails.

For testing, I have hardcoded a different url into the .load() part of the glide block and that works fine. Thus, I know that the layout is correct. I have also tried to hardcode the actual url that I am trying to fetch but it also fails.

The url is correct. I can paste it into a browser and the image loads instantly. There are two possible aspects of the url that maybe Glide doesn't like?? First, it is http rather than https. Second, it ends in ".jpg", where my other images typically are png's.

Glide.with(imageView.context).load(url).into(imageView)

I have checked that both imageView and imageView.context are non-null and of course that the url string is correct.

Totally out of ideas. Thanks.

Upvotes: 1

Views: 2908

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006594

You should be able to play with Glide's debugging options to get logs about the problems it encounters.

In your case, there should be logs somewhere indicating that you are getting the "CLEARTEXT communication not supported" exception, as https is required by default for Android 9.0+.

To resolve that, ideally just use https URLs. Alternatively, you can disable this requirement.

Upvotes: 4

Related Questions