Glide安卓9.0加载不出图片解决方案

本文介绍了一次使用Glide框架加载图片遇到的问题及解决方案。作者最初怀疑依赖问题,后发现是Android系统对明文通信的限制导致。解决办法是在AndroidManifest.xml中加入android:usesCleartextTraffic=true,允许应用使用HTTP等明文通信。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Glide是一个用于加载图片的框架,但这次却出了问题。。。加载不出图片了???


首先并没有什么骚操作,正常加载,一开始以为是依赖出了问题啥,一顿好找,摸不着头脑,但改了之后还是无法加载出来,这时我很大程度上就觉得是Android系统的问题了。最终还是和我想的一样。


解决方案


在AndroidManifest.xml加入android:usesCleartextTraffic="true"

    <application
        android:name=".MyApplication"
        ......
        android:usesCleartextTraffic="true"  />

 

Declare that this application may use cleartext traffic, such as HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP without STARTTLS or TLS). Defaults to true. If set to false {@code false}, the application declares that it does not intend to use cleartext network traffic, in which case platform components (e.g. HTTP stacks, {@code DownloadManager}, {@code MediaPlayer}) will refuse applications's requests to use cleartext traffic. Third-party libraries are encouraged to honor this flag as well.

 

声明此应用程序可以使用明文通信,例如http而不是https;websockets而不是websockets secure;xmpp、imap、stmp而不使用starttls或tls)。默认为true。如果设置为false{@code false},则应用程序声明不打算使用明文网络通信,在这种情况下,平台组件(例如http堆栈、{@code downloadmanager}、{@code mediaplayer})将拒绝应用程序使用明文通信的请求。我们也鼓励第三方库尊重它。

觉得是用来兼容低版本,看下面参考:

参考:

Android高版本联网失败报错:Cleartext HTTP traffic to xxx not permitted解决方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值