Android版本28使用http请求报错not permitted by network security policy
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
转载于:https://my.oschina.net/u/1177694/blog/3093265
- 点赞
- 收藏
- 分享
- 文章举报
- Android版本28使用http请求报错not permitted by network security policy
- Android9.0 使用http请求报错communication to not permitted by network security policy
- java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security polic
- Android经验总结--CLEARTEXT communication to zuojiacheapi.test.cheegu.com not permitted by network securi
- java.net.UnknownServiceException: CLEARTEXT communication to *** not permitted by network security p
- java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security polic
- Android访问网络失败:java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network
- Caused by: java.lang.SecurityException: Jurisdiction policy files are not signed by trusted signers!
- Android 分包导致低于5.0版本报错ClassNotFoundException
- mac版本idea使用(四) - 检出的项目运行时候报错:Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
- CentOS6.5 重启网络报错:Bringing up interface eth0: Error: Connection activation failed: Device not managed by NetworkManager or unavailable
- Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.HEADSET_PLUG
- ionic3添加android平台使用指定版本(解决没有升级Android Studio3.0的时候添加平台过高报错)
- java.lang.SecurityException: The jurisdiction policy files are not signed by a trusted signer!
- Android高版本联网失败报错:Cleartext HTTP traffic to xxx not permitted解决方法
- centos6.6重启网络报错Error: Connection activation failed: Device not managed by NetworkManager的解决办法
- Caused by: java.lang.SecurityException: Jurisdiction policy files are not signed by trusted sign...
- JAVA刚碰见的问题( java.lang.SecurityException: The jurisdiction policy files are not signed by a trusted s
- 使用npm install报错-4048 operation not permitted解决
- 使用npm install报错-4048 operation not permitted问题