okhttp无法网络的问题

  本以为是AVD没有网络,查度娘才知道原来是谷歌不支持没有https的不“安全”访问:

  在资源文件夹xml目录下建立文件Fres\xml\network_security_config.xml

<network-security-config>
     <!--默认允许所有网址使用非安全连接-->
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

  在配置文件中:

<application
        android:networkSecurityConfig="@xml/network_security_config"

  

posted @ 2020-11-07 03:20  风肖肖(肖遥)  阅读(596)  评论(0编辑  收藏  举报