应用官方的说明:在 Android 6.0 中,咱们取消了对 Apache HTTP 客户端的支持。 从 Android 9 开始,默认状况下该内容库已从 bootclasspath 中移除且不可用于应用。且Android P 限制了明文流量的网络请求,非加密的流量请求都会被系统禁止掉。android
错误日志:网络
CLEARTEXT communication to XXXXXXXX not permitted by network security policy加密
解决:spa
在res目录下新建xml文件夹,文件夹中新建文件network_security_config.xml,文件内容以下日志
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
在AndroidManifest.xml文件中,Application标签下添加以下属性:xml
android:networkSecurityConfig="@xml/network_security_config"
完美解决
-it