okhttp无法网络的问题

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

  在资源文件夹xml目录下建立文件Fresxml etwork_security_config.xml

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

  在配置文件中:

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

  

以前的是程序员的老板,现在是末路出家的程序员小白。
原文地址:https://www.cnblogs.com/xiaoyao-blog/p/13939718.html