Glide 无法加载某些图像因异常而失败
Glide not able to load some of images failed with exception
我在加载图片时遇到问题。只有一些图像未加载。我试过使用 glide 和 image loader。
滑行代码:
Glide.with(context)
.load(model.getImage4x3().trim()+"?w=430&h=275")
.into(holder.mBinding.ivPromotion);
滑动依赖:
implementation 'com.github.bumptech.glide:glide:4.9.0'
我也试过:3.9.0、4.0.0、3.6.1、3.8.0
错误:
load failed for http://mcms-uat.mercatus.com.sg/en/-/media/E3BE24B58E1144228C62D2364F4FF543.ashx?rev=50ebbcc572e6488c826a23276ab9bf08 with size [320x240]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There were 4 causes:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Object->Drawable}, DATA_DISK_CACHE, http://mcms-uat.mercatus.com.sg/en/-/media/E3BE24B58E1144228C62D2364F4FF543.ashx?rev=50ebbcc572e6488c826a23276ab9bf08
Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}
Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Drawable}
Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->BitmapDrawable->Drawable}
图片:
请查收!
1) Add below dependencies into app/build.gradle
annotationProcessor 'com.github.bumptech.glide:compiler:your_glide_version'
2) 将 android:largeHeap="true" 放入清单文件的标签
3) 并像下面那样使用
ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
Glide.with(context) // this
.load(imagePath)
.placeholder(R.drawable.loading_spinner)
.into(imageView);
glide加载大图有问题
要么使用毕加索库
implementation 'com.squareup.picasso:picasso:2.5.2'
或者您也可以使用 facebook 库,可以在他们的网站上找到(这也可以很好地加载 gif 图像)。
感谢大家的回答和建议。我已经解决了这个问题。我的 URL 参数有问题,它是 ?w=430&h=275
而不是 &w=430&h=275
。由于这张图片没有被裁剪,加载大图时出现问题,所以我通过更改参数解决了这个问题
只需使用此方法即可完成。如果它不起作用,那就去 Picasso Library,因为这个问题已经被 Glide 本身解决了。
Glide.with(context)
.asBitmap()
.load("Your Network Image Path")
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
iv.setImageBitmap(resource);
iv.buildDrawingCache();
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) { }
});
我在加载图片时遇到问题。只有一些图像未加载。我试过使用 glide 和 image loader。
滑行代码:
Glide.with(context)
.load(model.getImage4x3().trim()+"?w=430&h=275")
.into(holder.mBinding.ivPromotion);
滑动依赖:
implementation 'com.github.bumptech.glide:glide:4.9.0'
我也试过:3.9.0、4.0.0、3.6.1、3.8.0
错误:
load failed for http://mcms-uat.mercatus.com.sg/en/-/media/E3BE24B58E1144228C62D2364F4FF543.ashx?rev=50ebbcc572e6488c826a23276ab9bf08 with size [320x240]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There were 4 causes:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Object->Drawable}, DATA_DISK_CACHE, http://mcms-uat.mercatus.com.sg/en/-/media/E3BE24B58E1144228C62D2364F4FF543.ashx?rev=50ebbcc572e6488c826a23276ab9bf08
Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}
Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Drawable}
Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->BitmapDrawable->Drawable}
图片:
请查收!
1) Add below dependencies into app/build.gradle
annotationProcessor 'com.github.bumptech.glide:compiler:your_glide_version'
2) 将 android:largeHeap="true" 放入清单文件的标签
3) 并像下面那样使用
ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
Glide.with(context) // this
.load(imagePath)
.placeholder(R.drawable.loading_spinner)
.into(imageView);
glide加载大图有问题
要么使用毕加索库
implementation 'com.squareup.picasso:picasso:2.5.2'
或者您也可以使用 facebook 库,可以在他们的网站上找到(这也可以很好地加载 gif 图像)。
感谢大家的回答和建议。我已经解决了这个问题。我的 URL 参数有问题,它是 ?w=430&h=275
而不是 &w=430&h=275
。由于这张图片没有被裁剪,加载大图时出现问题,所以我通过更改参数解决了这个问题
只需使用此方法即可完成。如果它不起作用,那就去 Picasso Library,因为这个问题已经被 Glide 本身解决了。
Glide.with(context)
.asBitmap()
.load("Your Network Image Path")
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
iv.setImageBitmap(resource);
iv.buildDrawingCache();
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) { }
});