Android9.0系统 请求不到Http网络数据

Android9.0 默认是禁止所有的http

提示错误:

System.err: java.io.IOException: Cleartext HTTP traffic to **** not permitted

OKHttp请求则出现:

java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security policy

三种解决方案:

1、APP改用Https请求

2、targetSdkVersion 降到27以下

3、在 res 下新增一个 xml 目录,然后创建一个名为:network_security_config.xml 文件(名字自定) ,内容如下,大概意思就是允许开启http请求



    

然后在APP的AndroidManifest.xml文件下的application标签增加以下属性

参考原文:https://www.cnblogs.com/renhui/p/9921790.html

你可能感兴趣的:(android,请求网络数据,android9.0,打包,Cleartext,HTTP,CLEARTEXT,communication,not,permitted)