Failure to load resource by GlideException in com.bumptech.glide.load.engine

Today, I encountered the same error as I have been using yande’s API frequently. Hence, I believe there are two possible reasons for this issue. First, it could be due to excessive requests made by the glide at one time, causing the yande server to refuse response. Secondly, if you are using a spider to display yande’s pictures, you need to configure it to resemble an Internet Explorer by adding headers to the HTTP request.
Here are some references that might assist you:
– Glide – adding headers to the request
– Yande API
In any case, when writing code for a spider, it is crucial to consider the website from which we are retrieving information.

Question:

I am attempting to load an image into
imageView
using Glide. However, I encounter an error and the image does not load. The code I am using is as follows.

GlideApp.with(context)
    .load(itemData.getThumbnailUri())
    .placeholder(R.mipmap.koya_logo_white)
    .error(R.mipmap.ic_image_loading_error)
    .into(itemBinding.cover);

Logs

lide: Load failed for https://s3.amazonaws.com/koya-dev-videos/kindness/8da807aa-1e1e-413d-bf9b-5bb084646593/medialibrary/9456621508/videos/1eb78337-d569-41bd-95ad-153d9098de03.png with size [1080x1080]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{StringUri->Object->Drawable}, LOCAL, DataCacheKey{sourceKey=https://s3.amazonaws.com/koya-dev-videos/kindness/8da807aa-1e1e-413d-bf9b-5bb084646593/medialibrary/9456621508/videos/1eb78337-d569-41bd-95ad-153d9098de03.png, signature=EmptySignature}
Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{StringUri->Drawable->Drawable}
Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{StringUri->Bitmap->Drawable}



Solution 1:

The lack of internet connection on the phone/emulator is another factor contributing to the occurrence of this issue.


Solution 2:


Consider giving this solution a try…

String url = "https://s3.amazonaws.com/koya-dev-videos/kindness/8da807aa-1e1e-413d-bf9b-5bb084646593/medialibrary/9456621508/videos/1eb78337-d569-41bd-95ad-153d9098de03.png";
    
GlideApp.with(context).load(url)
        .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
        .error(R.drawable.glide_app_img_loader)
        .listener(new RequestListener() {
             @Override
             public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
                 return false;
             }
    
             @Override
             public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
                 return false;
             }
        }).into(imageView);


Solution 3:


The solution is effective for me by following these steps:
1. Make changes to the build.gradle(Module: app) file.

    implementation "com.github.bumptech.glide:glide:4.7.1"
        kapt "com.github.bumptech.glide:compiler:4.7.1"
        implementation "com.squareup.okhttp3:okhttp:3.14.0"
        implementation ('com.github.bumptech.glide:okhttp3-integration:4.7.1'){
            exclude group: 'glide-parent'
        }

  1. Set timeout for glide

     @GlideModule
        class MyAppGlideModule : AppGlideModule() {
            override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
                val client = OkHttpClient.Builder()
                    .readTimeout(30, TimeUnit.SECONDS)
                    .connectTimeout(30, TimeUnit.SECONDS)
                    .build()
                val factory = OkHttpUrlLoader.Factory(client)
                glide.registry.replace(GlideUrl::class.java, InputStream::class.java, factory)
            }
        }
     


Solution 4:

The most straightforward answer.

add,

android:usesCleartextTraffic="true"

Within the
<application/>
tag located in your
AndroidManifest.xml
file.

Frequently Asked Questions