com.bumptech.glide.load.engine.GlideException类:无法加载资源

nar*_*rma 13 android image android-glide

我正在尝试imageView通过Glide 将图像加载到其中。但是图像未加载-我收到错误消息。我正在使用以下代码

GlideApp.with(context)
    .load(itemData.getThumbnailUri())
    .placeholder(R.mipmap.koya_logo_white)
    .error(R.mipmap.ic_image_loading_error)
    .into(itemBinding.cover);
Run Code Online (Sandbox Code Playgroud)

日志

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]
Run Code Online (Sandbox Code Playgroud)
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}
Run Code Online (Sandbox Code Playgroud)

Vis*_*ani 6

尝试这个解决方案...

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<Drawable>() {
             @Override
             public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                 return false;
             }
    
             @Override
             public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                 return false;
             }
        }).into(imageView);
Run Code Online (Sandbox Code Playgroud)


Anh*_*Duy 6

该解决方案对我有用:
1.更新 build.gradle(Module: app)

    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'
        }
Run Code Online (Sandbox Code Playgroud)
  1. 设置滑行超时时间

     @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)
            }
        }
    
    Run Code Online (Sandbox Code Playgroud)


Iev*_*gen 6

出现此问题的另一个原因是手机/模拟器没有互联网连接。


Kis*_*nki 6

最简单的解决方案

添加,

android:usesCleartextTraffic="true"
Run Code Online (Sandbox Code Playgroud)

在你的文件<application/>标签内AndroidManifest.xml


sas*_*mar 1

我也遇到了这个问题。它来自 glide 方面的错误。使用最新版本的 glide。

repositories {
 mavenCentral()
 google()
}

dependencies {
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
Run Code Online (Sandbox Code Playgroud)

确保 itemData.getThumbnailUri() 不包含空格