-1

I am using Glide to load images from url onto an ImageView in a RecyclerView adapter. Everything works fine when a user is connected to the internet on wifi. However, when their connection is on mobile data, Glide throws an exception:

java.io.FileNotFoundException: "http://......png" at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream()

Any help would be appreciated.

I have tried using https but still the same issue persists. Also tried almost all other image loading libraries including UniversalImageLoader, Fresco, Picasso but still the same error persists

hata
  • 11,633
  • 6
  • 46
  • 69
Don Louis
  • 61
  • 1
  • 7

2 Answers2

0

Try to put this line in AndroidManifest.xml:

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

Probably WiFi is working globally on device, while mobile data is some sort of custom network state. in this tutorial (at FutureStud.io) use of Glide 4.x is shown. You can check connection from there and probably advance your debugging process, although the uses-permission snippet should work.

C0nverter
  • 114
  • 13
-1

Please use an async image loading and caching library similar to koush/ion Check this

Ion.with(context)
.load("http://example.com/image.png")
.withBitmap()
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.animateLoad(spinAnimation)
.animateIn(fadeInAnimation)
.intoImageView(imageView);

It's easy for you to implement and cache it too. remember to add neccersery manifest permissions. Hope you this helps!! Cheers

dependencies {
  implement 'com.koushikdutta.ion:ion:2.+'
}

add this to your dependencies.

Viroj Fernando
  • 461
  • 4
  • 8