为啥 Glide 没有在 android 中加载 https 图像?

Posted

技术标签:

【中文标题】为啥 Glide 没有在 android 中加载 https 图像?【英文标题】:Why Glide is not loading https images in android?为什么 Glide 没有在 android 中加载 https 图像? 【发布时间】:2017-05-29 14:19:44 【问题描述】:

我正在尝试使用 Glide 在 imageview 中加载 https 图像。图像未加载,但如果我提供一些本地图像(例如 R.drawable.error_image),它会加载。

imagePath = "https://s-media-cache-ak0.pinimg.com/736x/d3/6b/83/d36b83e986e500aa7f39c722970f1f97.jpg"; // 示例图片取自网络

Glide.with(this)
      .load(imagePath)
      .into(landingImage);
compile 'com.github.bumptech.glide:glide:4.0.0-RC0'

我也尝试在 SOF 中搜索,但没有得到修复。提前给建议谢谢。

【问题讨论】:

你尝试调试了吗? “如果我提供一些将加载的错误图像”是什么意思?如果您使用本地图像,或者...?不同的网址? @Markon 感谢您宝贵的时间。错误图像意味着 - 我的项目中可绘制的图像 【参考方案1】:

尝试降级到以前的某个版本。

compile 'com.github.bumptech.glide:glide:3.7.0'

看看这个答案: Glide does not resolve its method

【讨论】:

【参考方案2】:

是的,它不起作用,我在毕加索和滑翔中发现了同样的问题 也,但我已经通过使用下面的链接解决了。

android-Universal-Image-Loader

【讨论】:

随时为您的主张提供证据。作为一个反例,this sample app 加载 HTTPS 图像很好(毕加索,不是 Glide)。【参考方案3】:

使用依赖 Android-Universal-Image-Loader 对我有用

implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

加载图片

private DisplayImageOptions options;
private void LoadImage(String image_url) 

    ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(getActivity()));

    options = new DisplayImageOptions.Builder()
            .showImageOnFail(R.drawable.ic_error)
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .considerExifParams(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .displayer(new RoundedBitmapDisplayer(20))
            .build();


    ImageLoader imageLoader = ImageLoader.getInstance();
    //mImageViewOne : image view 
    imageLoader.displayImage(image_url,mImageViewOne,options);

【讨论】:

以上是关于为啥 Glide 没有在 android 中加载 https 图像?的主要内容,如果未能解决你的问题,请参考以下文章

当我尝试在 Android NDK 中加载冻结模型时,为啥没有注册操作?

Picasso 图片在 android 中加载缓慢,为啥?

java 完整的POC,用于显示通过OkHttp v2在Glide v3中加载的进度

当我在我的 android 应用程序中从图库中加载图像时,为啥位图返回较小的图像?

为啥在 Web 浏览器中工作的 url 没有在 UIImageview 中加载

滑行,线圈不在模拟器中加载图像