Picasso image loading issue with Android 9.0 Pie

只愿长相守 提交于 2019-11-30 12:32:19

Try Using android:usesCleartextTraffic="true" in Application Tag of your Manifest file! As i faced same issue using Android Volley!

As per Android Documentation

Indicates whether the app intends to use cleartext network traffic, such as cleartext HTTP. The default value is "true". When the attribute is set to "false", platform components (for example, HTTP and FTP stacks, DownloadManager, MediaPlayer) will refuse the app's requests to use cleartext traffic. Third-party libraries are strongly encouraged to honor this setting as well. The key reason for avoiding cleartext traffic is the lack of confidentiality, authenticity, and protections against tampering: a network attacker can eavesdrop on transmitted data and also modify it without being detected. link

I know the answer with android:usesCleartextTraffic="true" works but this will allow all connexions to be http not s on everything, which I suppose is not what you want in 2018.

If you know the domain you're reaching in http and you trust it, then it is better to use the network security configuration.

Define a xml file in res/xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">secure.example.com</domain>
    </domain-config>
</network-security-config>

See the cleartextTrafficPermitted="true" only for secure.example.com and its subs.

And then in your AndroidManifest.xml, add android:networkSecurityConfig="@xml/network_security_config"

You can add multiple domains, with multiple configuration, ensure some of them are https or the opposite. Looks more secured IMHO.

Nawal Ayed

In my case, I just changed the image url from http to https and it worked on API 28 without adding anything to my manifest file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!