Search code examples
androidkotlinandroid-glide

Glide does not load images


My code is standard:

options = options.transforms(CenterCrop(), RoundedCorners(3.px))
                Glide.with(itemView.context).load(flower.profilePicture.prefixHttp())
                    .apply(options)
                    .transition(
                        DrawableTransitionOptions.withCrossFade()
                    ).into(flowerImage)

I debugged and get

flower.profilePicture.prefixHttp() = http://flowrspot.s3.amazonaws.com/flowers/profile_pictures/000/000/007/medium/L_00010.jpg?1527514226

which is totally fine. I tried with multiple dependencies:

//    implementation 'com.github.bumptech.glide:glide:4.8.0'
//    kapt 'com.github.bumptech.glide:compiler:4.8.0'

    implementation 'com.github.bumptech.glide:glide:4.14.2'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'

But it just does not load. In my logcat I get some warnings/errors written:

"Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored"

"Load failed for [http://flowrspot.s3.amazonaws.com/flowers/profile_pictures/000/000/007/medium/L_00010.jpg?1527514226] with dimensions [420x525] class com.bumptech.glide.load.engine.GlideException: Failed to load resource There was 1 root cause: com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE There was 1 root cause: com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed There was 1 root cause: com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: -1"

What is going on here. Never seen glide behave like this...


Solution

  • By setting the usesCleartextTraffic attribute to true in your Android app's AndroidManifest.xml file allows the app to make network requests to HTTP (non-HTTPS) URLs.

    Because, starting from Android 9 (Pie), the default value of usesCleartextTraffic is false (disabled), which means that apps are not allowed to make network requests to HTTP URLs.