Caused by : java.io.IOException: Cleartext HTTP traffic to 《“url”》 not permitted
一、问题原因:
根本原因是从Android9.0开始,出于完全因素考虑,默认不再支持http网络请求,需要使用 https。
二、解决方案:
解决的基本思路是:对指定的网址进行过滤,强制允许指定网址继续使用http请求
参考地址1:https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted
参考地址2:https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted
参考地址3: https://koz.io/android-m-and-the-war-on-cleartext-traffic/
下列解决步骤基于参考地址1整理:
方案 1:
A:创建 res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">Your URL(ex: 127.0.0.1)</domain>
</domain-config>
</network-security-config>
注意:上述代码的意思是解除对指定网址的限制。
B:修改 AndroidManifest.xml
配置 android:networkSecurityConfig
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:networkSecurityConfig="@xml/network_security_config"
...>
...
</application>
</manifest>
方案 2:
A:修改AndroidManifest.xml
启用 android:usesCleartextTraffic
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>
方案 3:
在 @david.s'的回答中指出 也可能会导致该问题 -
在 Manifest Docs https://developer.android.com/guide/topics/manifest/manifest-element#targetSandboxVersion中对于 有如下描述
android:targetSandboxVersion
The target sandbox for this app to use. The higher the sandbox version number, the higher the level of security. Its default value is 1; you can also set it to 2. Setting this attribute to 2 switches the app to a different SELinux sandbox. The following restrictions apply to a level 2 sandbox:
The default value of usesCleartextTraffic in the Network Security Config is false.Uid sharing is not permitted.
所以,如果你在 AndroidManifest.xml 的节点中配置了 ,需要将它的值置为1.
A:修改AndroidManifest.xml
降低 android:targetSandboxVersion 的版本
<?xml version="1.0" encoding="utf-8"?>
<manifest android:targetSandboxVersion="1">
<uses-permission android:name="android.permission.INTERNET" />
...
</manifest>
Caused by : java.io.IOException: Cleartext HTTP traffic to 《“url”》 not permitted的更多相关文章
- java.io.IOException: Cleartext HTTP traffic to xxx.xxx.xxx.xxx not permitted
java.io.IOException: Cleartext HTTP traffic to xxx.xxx.xxx.xxx not permitted 转 https://blog.csdn.net ...
- eclipse连接远程Hadoop报错,Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。
eclipse连接远程Hadoop报错,Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接.全部报错信息如下: Exception in thread & ...
- hive对于lzo文件处理异常Caused by: java.io.IOException: Compressed length 842086665 exceeds max block size 67108864 (probably corrupt file)
hive查询lzo数据格式文件的表时,抛 Caused by: java.io.IOException: Compressed length 842086665 exceeds max block s ...
- Caused by: java.io.IOException: Filesystem closed的处理
org.apache.hadoop.hive.ql.metadata.HiveException: Unable to rename output from: hdfs://nameservice/u ...
- Caused by: java.io.IOException: 你的主机中的软件中止了一个已建立的连接。
org.apache.catalina.connector.ClientAbortException: java.io.IOException: 你的主机中的软件中止了一个已建立的连接. at org ...
- spark bulkload 报错异常:Caused by: java.io.IOException: Added a key not lexically larger than previous
------------恢复内容开始------------ Caused by: java.io.IOException: Added a key not lexically larger than ...
- Caused by: java.io.IOException: 您的主机中的软件中止了一个已建立的连接。
异常详情 2017-07-16 10:55:26,218 ERROR [500.jsp] - java.io.IOException: 你的主机中的软件中止了一个已建立的连接. org.apache. ...
- Caused by: java.io.IOException: Added a key not lexically larger than previous.
为了重复这个实验,遇到不少坑 https://www.iteblog.com/archives/1889.html /** * Created by Administrator on 2017/8/1 ...
- Push notification - Caused by java.io.IOException toDerInputStream rejects tag
苹果推送 : 文件不是P12文件当生成一个P12,需要选择两个,在钥匙串访问的私钥和证书.
随机推荐
- Oracle中对XMLType的简单操作(extract、extractvalue...)
Oracle中对XMLType的简单操作(extract.extractvalue...) 1.下面先创建一个名未test.xml的配置文件. <?xml version="1. ...
- 解决页面使用ifrmae后,在session失效后登录页面在子页面中显示(子窗体出现父窗体)
在登录页面中添加js判断当前页面是否是父页面,诺不是则父页面跳转至登录页面. <script type="text/javascript"> //解决登录后多个父窗体问 ...
- C++ 自定义订单号
自定义订单号 #include<iostream> #include<stack> #include <time.h> #include <sys/timeb ...
- 阿里云mysql安装配置(CentOS 7.3 64)
自建目录并且加载yum资源mysql 安装 回车之后竟然出现不可以的情况(原因是原来的镜像里面默认装好了mysql5.7) 然后只能尝试跳过密码登录 #vim /etc/my.cnf 在文档内搜索my ...
- Kendo DropDownListFor值传不回去的小坑
做项目时,在KendoWindow弹框里面写了个表单提交,不小心把AreaId 下拉框设置了Name为“OrderAreaId”.在后台接收不到AreaId的参数.后来才发现是Name的设置强行把A ...
- vue图片onerror加载路径写法
vue里,img加载错误的时候,onerror属性可以加载错误图片的默认图片写法如下: <img class=avator' :src="data.picture" :one ...
- hive的常见判断与抽样函数
.If函数:if和case差不多,都是处理单个列的查询结果 语法: if(boolean testCondition, T valueTrue, T valueFalseOrNull) 返回值: T ...
- 使用OGG添加唯一标识字段到目标表
利用GoldenGate,可以获取到变更记录在源端对应的redo日志序号,redo中的地址RBA,如果源端是RAC,还可以拿到源端节点的编号,通过这3个值,可以定位该变更记录的唯一性. 这些信息,在G ...
- ps top 命令
pstree :显示进程树 ps: a:查看和终端有关的进程 u:显示进程是哪个用户启动的 x:和终端无关 ps aux |head 进程的分类: 和终端有关 和终端无关 进程状态: D:不可中断睡眠 ...
- Windows环境下最新OpenCV和Contribute代码的联合编译【20180926更新红字】
解决这个问题,目的在于获得并使用最新的完全版本的代码,主要方法是对CMake能够熟练使用,并且对编译等基础支持有所了解. 因为这篇博客经过多次修改,所以里面的内容和配图可能有不是完全比对的地方,但是只 ...