Android版本28使用http请求报错not permitted by network security policy

android模拟器调试登录的时候报错 CLEARTEXT communication to to 52.76.xx.xxx not permitted by network security policy

2018-10-17 20:42:09.532 18048-18048/com.aax.exchange E/ProgressObserver____: onError:
java.net.UnknownServiceException: CLEARTEXT communication to 52.76.xx.xxx not permitted by network security policy

问题: 由于 Android P(版本27以上) 限制了明文流量的网络请求,非加密的流量请求都会被系统禁止掉。
如果当前应用的请求是 htttp 请求,而非 https ,这样就会导系统禁止当前应用进行该请求

推荐的做法是服务器和本地应用都改用 https ,测试时为了方便使用http,上线时应该都会用https才比较安全。

解决办法:1.在 res 下新建一个 xml 目录,然后创建一个名为:network_security_config.xml 文件 ,该文件内容如下:

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

在 AndroidManifest.xml application增加配置android:networkSecurityConfig="@xml/network_security_config"

后不报错了

2:服务器和本地应用都改用 https (推荐)

3:targetSdkVersion 降级回到 27

Android版本28使用http请求报错not permitted by network security policy的更多相关文章

  1. Android版本28使用http请求

    Android版本28使用http请求报错not permitted by network security policy android模拟器调试登录的时候报错 CLEARTEXT communic ...

  2. 安卓工作室 android studio 汉化后,报错。 设置界面打不开。Can't find resource for bundle java.util.PropertyResourceBundle, key emmet.bem.class.name.element.separator.label

    安卓工作室 android studio 汉化后,报错. 设置界面打不开. Android studio has been sinified and reported wrong.The setup ...

  3. mysql 5.7.28 中GROUP BY报错问题 SELECT list is not in GROUP BY clause and contains no

    ----mysql 5.7.28 中GROUP BY报错问题 SELECT list is not in GROUP BY clause and contains no------ 解决方案: sel ...

  4. Android Studio使用org.apache.http报错

    Android Studio使用org.apache.http报错需要加上这句话:useLibrary 'org.apache.http.legacy'

  5. Xcode7 beta 网络请求报错:The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

    Xcode7 beta 网络请求报错:The resource could not be loaded because the App Transport Xcode7 beta 网络请求报错:The ...

  6. Xcode7 beta 网络请求报错:The resource could not be loaded because the App Transport

    Xcode7 beta 网络请求报错:The resource could not be loaded because the App Transport Xcode7 beta 网络请求报错:The ...

  7. nuget包管理nuget服务器发布包时出现请求报错 406 (Not Acceptable)

    在window服务器上部署nuget服务器时,发布包时出现请求报错 406 (Not Acceptable) 验证用户名.密码正确的情况下,还是出现上面错误.后面跟踪服务器日志,发现window\te ...

  8. git https 请求报错 504

    git https 请求报错 504 原因可能是因为设置了代理,ubuntu/deepin 系统可以检查 /etc/profile ~/.bashrc 内有没有设置 https 的代理. 有的话,去掉 ...

  9. JS请求报错:Unexpected token T in JSON at position 0

    <?php /* 最近做一个ajax validate表单验证提交的代码,在ajax提交的时候 JS请求报错:Unexpected token T in JSON at position 0 描 ...

随机推荐

  1. VC++ 实现INI文件读写操作

    转载:https://blog.csdn.net/fan380485838/article/details/73188420 在实际项目开发中,会用ini配置文件,在此总结一下对ini读写操作 一:读 ...

  2. SVN冲突以及解决办法

    1.冲突原因: 假设 A.B 两个用户都在版本号为 100 的时候,更新了 kingtuns.txt 这个文件,A 用户在修改完成之后提交 kingtuns.txt 到服务器, 这个时候提交成功,这个 ...

  3. selenium+java利用AutoIT实现文件上传

    转自https://www.cnblogs.com/yunman/p/7112882.html?utm_source=itdadao&utm_medium=referral 1.AutoIT介 ...

  4. redux-thunk的理解

    问题:1.redux-thunk要解决什么问题? 要解决异步请求问题,Action发出以后,Reducer立即算出State,这叫做同步:Action发出以后,过一段时间再执行 Reducer,这就叫 ...

  5. python from entry to abandon2

    学习Linux已经有大致两周了,依然感觉到自己仍然在运维的大门外徘徊.于是我想要找到一个在Linux之外的业余方向,可以以作为枯燥基础学习的调节.没过多久我就发现了Python可以说是钦定的选择,它作 ...

  6. python基础知识点三

    内置函数和匿名函数 python 一共有68个内置的函数:它们就是python提供给你直接可以拿来使用的所有函数 内置函数的图:链接 :https://www.processon.com/mindma ...

  7. fast-route的使用

    <?php require 'vendor/autoload.php'; // 通过 FastRoute\simpleDispatcher() 方法定义路由,第一个参数必须是 FastRoute ...

  8. EL函数库及用法

    导入标签库: <%@ tablib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%&g ...

  9. cout关闭输出缓冲,调试用

    cout.setf(std::ios::unitbuf);

  10. day15_python_1124

    03序列化模块 04加密模块 05 os sys 模块 06 collections 模块 # 03 序列化模块 # 网络传输数据:字节 bytes# 文件写入内容:bytes , str # dic ...