Android经验总结--CLEARTEXT communication to zuojiacheapi.test.cheegu.com not permitted by network securi
2019-04-11 11:05
218 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/warmming/article/details/89205505
Android经验总结–CLEARTEXT communication to zuojiacheapi.test.cheegu.com not permitted by network security policy
标签(空格分隔): Android
使用okhttp3进行网络请求的时候报以上的错误。
出现这个错误的原因是由于Android P限制了明文流量的网络请求,非加密的流量请求都会被系统禁止掉。
摸索了一段时间加上查看他人的经验,总结解决方法如下:
- 将targetSdkVersion改为27,(视情况选择,会出现编译错误的现象)
- 该为https请求(推荐)
- android:usesCleartextTraffic=“true”
- 在res目录下创建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" </application>
相关文章推荐
- java.net.UnknownServiceException: CLEARTEXT communication to *** not permitted by network security p
- Android访问网络失败:java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network
- Android9.0 使用http请求报错communication to not permitted by network security policy
- java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security polic
- java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security polic
- Android okhttp: "java.net.UnknownServiceException: CLEARTEXT communication to *** not permit"
- Android高版本联网失败报错:Cleartext HTTP traffic to xxx not permitted解决方法
- 安卓P提示 java.io.IOException: Cleartext HTTP traffic to dict.youdao.com not permitted
- Android p 使用bmob错误:java.net.UnknownServiceException:CLEARTEXT communication not supported:......
- java.lang.SecurityException: Not allowed to bind to service Intent { act=com.android.testAIDLServic
- Android版本28使用http请求报错not permitted by network security policy
- Caused by: android.content.res.Resources$NotFoundException: Resource "com.lvche.lvchedingdang:drawab
- Xamarin体验:使用C#开发iOS/Android应用(此文章为收藏博客,不是个人经验) by----作者:囧月 出处:http://lwme.cnblogs.com/
- 关于android的javaMail中的could not connect to STMP.qq.com的一些问题
- 问题解决Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve
- Android异常总结---ActivityManager: Warning: Activity not started,its current task has been brought to th
- Could not find com.android.databinding:library:1.2.1. Required by: XXXXX:app:unspecified
- Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.suppor
- SFTP连接异常 Could not connect to SFTP server. Caused by: com.jcraft.jsch.JSchException: Auth fail
- Android单元测试异常总结---Test run failed:Unable to find instrumentation target package