Glide 4.0报错

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wu_zi/article/details/81010727

昨天在使用Glide的时候加载不出来图片,同一张图片使用Picasso加载没问题,报错日志如下:

07-12 09:47:23.486 25562-25562/allenhu.app E/Glide: class com.bumptech.glide.load.engine.GlideException: Failed to load resource
07-12 09:47:23.486 25562-25562/allenhu.app W/Glide: Load failed for http://i2.meizitu.net/2018/07/06a04.jpg with size [984x1381]
                                                    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
                                                      Cause (1 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Bitmap->Bitmap}, DATA_DISK_CACHE, http://i2.meizitu.net/2018/07/06a04.jpg
                                                        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Bitmap}
                                                      Cause (2 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Bitmap->Bitmap}, DATA_DISK_CACHE, http://i2.meizitu.net/2018/07/06a04.jpg
                                                        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->Bitmap}
                                                      Cause (3 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Bitmap->Bitmap}, DATA_DISK_CACHE, http://i2.meizitu.net/2018/07/06a04.jpg
                                                        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->Bitmap}
                                                      Cause (4 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Bitmap->Bitmap}, REMOTE, http://i2.meizitu.net/2018/07/06a04.jpg
                                                        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Bitmap}
                                                      Cause (5 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Bitmap->Bitmap}, REMOTE, http://i2.meizitu.net/2018/07/06a04.jpg
                                                        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->Bitmap}
                                                      Cause (6 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Bitmap->Bitmap}, REMOTE, http://i2.meizitu.net/2018/07/06a04.jpg
                                                        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->Bitmap}
07-12 09:47:23.486 25562-25562/allenhu.app E/Glide: class com.bumptech.glide.load.engine.GlideException: Failed to load resource

加载图片的代码如下:

options = new RequestOptions();
        options.fitCenter();
        options.error(R.drawable.ic_error);
        options.placeholder(R.drawable.ic_default_image);
//        options.dontAnimate();
        options.diskCacheStrategy(DiskCacheStrategy.ALL);
 Glide.with(context)
                .asBitmap()
                .load(url)
                .thumbnail(0.2f)
                .apply(options)//
                .into(imageView);

结论:在网上找了很多资料,包括看Glide在GitHub上的issue,但是未找到原因和解决方案。

最后发现使用上面的代码,在4G网络下很快就加载出来了。但是用公司wifi就加载不出来。可能是WiFi原因。



猜你喜欢

转载自blog.csdn.net/wu_zi/article/details/81010727