这里简单的用了聚合免费的接口写了一个demo,专门来解决这个bug


搭建完MVP框架后,设置baseUrl开始请求。找了好久感觉没问题,后来查了资料才知道,是我们的baseUrl的问题
因为是内部测试环境所以使用的是ip地址,或者http://

原因:

  1. Android P系统网络访问安全策略升级,限制了非加密的流量请求
  2. Android P系统限制了明文流量的网络请求,之下的版本没有影响,所以okhttp3会抛出该异常

处理方法:

  1. 降低目标版本,app/build.gradle中targetSdkVersion 设置27或以下
  2. http请求改成https
  3. 添加res/xml/network_security_config.xml文件名可自拟



代码如下:

 <?xml version="1.0" encoding="utf-8"?>
<network-security-config><base-config cleartextTrafficPermitted="true" />
</network-security-config>

网络请求未知错误 CLEARTEXT communication to XX not permitted by network security policy 解决方案相关推荐

  1. 安卓9.0系统出现 CLEARTEXT communication to XX not permitted by network security policy

    1.原因:由于2018年发布的Android P限制了非加密的流量请求导致出现 not permitted by network security policy 2.解决方法: (1)把所有的http ...

  2. CLEARTEXT communication to xxx not permitted by network security policy

    2019独角兽企业重金招聘Python工程师标准>>> Android P http网络请求不通,报出异常:java.net.UnknownServiceException: CLE ...

  3. 关于网络请求报错:CLEARTEXT communication to xx.xx.xx.xx not permitted by network security policy

    问题 高版本Android项目运行报错:CLEARTEXT communication to xx.xx.xx.xx not permitted by network security policy ...

  4. Android 9.0以上联网报错:CLEARTEXT communication to xxx.xxx.xxx.xx not permitted by network security policy

    Google为了保证用户数据和设备安全,针对Android 系统(Android P) 的应用程序,将要求默认使用加密连接.Android P 将禁止 App 使用所有未加密的连接,因此运行 Andr ...

  5. 网络请求失败CLEARTEXT communication to “ “ not permitted by network security policy

    ok http3 + retrofit 网络请求,在Android9.0手机上请求失败,报错:CLEARTEXT communication to " " not permitte ...

  6. 【Android】【网络请求】解决cleartext communication not permitted问题

    androidSDK从9.0开始,强制要求使用https协议 如果使用了9.0以上的SDK,但没有使用https协议,就会报以下错误: CLEARTEXT communication not perm ...

  7. CLEARTEXT communication to “ “ not permitted by network security policy处理办法

    ok http3 + retrofit 网络请求,在Android9.0手机上请求失败,报错:CLEARTEXT communication to " " not permitte ...

  8. error:CLEARTEXT communication to api.help.bj.cn not permitted by network security policy

    这个问题出现的原因是Android P系统限制了明文流量的网络请求 处理方法就是 1 首先需要在res 目录下创建一个xml 包然后在创建一个xml  如下图 里面的内容 <?xml versi ...

  9. 请求时出现:not permitted by network security policy

    原因:Android P之后系统限制了明文的网络请求,非加密请求会被系统禁止掉. 使用OkHttp3做网络请求框架时,如果是http请求而非https请求,会导致请求失败 同样如果您使用了WebVie ...

最新文章

  1. Vivado 中IP报严重警告Could not find module的解决办法
  2. 手机pc显示不同的内容
  3. youtube获取播放列表信息
  4. 关于Action模型驱动无法获取属性的问题
  5. python 密度聚类 使用_使用python+sklearn实现硬币图像上的结构化Ward层次聚类演示...
  6. priority_queue 优先队列
  7. 微信电话本的未来在农村
  8. [core java学习笔记][第十一章异常断言日志调试]
  9. 变量不在选择列表中_Python3中的表达式运算符
  10. rocketmq概念
  11. 关于visual studio和vc版本之间的对应关系(更新至2020.07)
  12. fspecial matlab 自己实现,matlab中fspecial中生成高斯模板的解释以及c语言兑现
  13. 根据名称获取对应的拼音码首字母大写
  14. java中extend与implement的区别
  15. pytorch 语⾔模型数据集(周杰伦专辑歌词)数据集 免费
  16. 360全景拍摄中相机的白平衡设置
  17. 玩家访问网站自动弹窗加QQ群方法以及详细代码
  18. 2020-10-11
  19. Vagrant安装和使用
  20. 2020.09.16 记录学习的点滴

热门文章

  1. numpy均匀分布_Numpy的基本操作
  2. 写给程序猿的把妹指南
  3. Echarts 修改X轴字体大小
  4. 《模型思维》—— 斯科特.佩奇
  5. 阿蒙森 斯科特_斯科特的糖尿病解释:飞机类比
  6. 设置IE主页的几种方法
  7. android开发自定义键盘,Android 总结:自定义键盘实现原理和三种实例详解
  8. 字符串函数 tirm 的作用
  9. python-短网址批量还原
  10. HomeBank-5.5.4-个人家庭记账分析软件(开源)