解决Android9.0 http无法请求

在 res 下新建一个xml目录,然后创建一个名为:network_config.xml 文件(名字自定),内容如下

<?xml version=”1.0″ encoding=”utf-8″?>

<network-security-config>

    <base-config cleartextTrafficPermitted=”true” />

</network-security-config>

在Mainfiests  appliction标签下配置该属性

 android:networkSecurityConfig="@xml/network_config"

即可解决,9.0系统不允许http协议访问网络的限制。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注