最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Android Glide加载网络图片不显示,但浏览器能打开图片

运维笔记admin1浏览0评论

使用Glide版本:4.8.0

implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'

已添加网络权限

<uses-permission android:name="android.permission.INTERNET" />

但是加载不出来图片。

经过查询,问题出在Android版本上:Android9.0包括之后默认的网络访问方式是https的,如果图片是http的,就需要设置一下。

解决方法:在res下新建一个xml文件夹,然后在xml文件夹下新建network_security_config.xml

network_security_config.xml代码如下:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

 然后在AndroidManifest.xml里面的application标签中添加:

这就可以了。 

发布评论

评论列表(0)

  1. 暂无评论