无法加载资源而没有异常详细信息

时间:2018-12-14 18:06:03

标签: android android-glide

我使用Glide将图像的URL加载到图像视图,如下所示:

RequestOptions requestOptions = new RequestOptions().placeholder(R.drawable.image_place_holder).error(R.drawable.image_place_holder);

Glide.with(imageView.getContext())
           .load(url)
           .listener(new RequestListener() {
                     @Override
                     public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
                            // Log the GlideException here (locally or with a remote logging framework):
                            Log.e(TAG, "Load failed", e);
                            e.printStackTrace();

                            // You can also log the individual causes:
                            for (Throwable t : e.getRootCauses()) {
                                Log.e(TAG, "Caused by", t);
                            }
                            // Or, to log all root causes locally, you can use the built in helper method:
                            e.logRootCauses(TAG);

                            return false; // Allow calling onLoadFailed on the Target.
                    }

                    @Override
                    public boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
                            return false;
                        }
                    })
   .apply(requestOptions)
   .into(imageView);

但是Glide在onLoadFailed()中抛出异常,并显示占位符图像:

  

滑行:https://abc.xyz/image.png的加载失败,大小为[736x388]

     

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

     

TAG:加载失败

     

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

您可以看到该异常没有原因,并且无法打印堆栈跟踪。

enter image description here

我尝试使用Picasso库或更改为另一个URL,它起作用了! 但是我不明白图像链接会发生什么。你能在这里解释这个问题吗?

0 个答案:

没有答案