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,需要选择两个,在钥匙串访问的私钥和证书.
随机推荐
- ==还款-代偿(csv循环自动代偿)
问题: 解决:传递参数错误,上一步就错了 问题:代偿返回这些信息 解决:传递参数错误,应该为${repayWay1},但是一直写的是${repayWay} 问题:如何从csv文件中逐条取项目编号,进行 ...
- pandas处理时间序列(4): 移动窗口函数
六.移动窗口函数 移动窗口和指数加权函数类别如↓: rolling_mean 移动窗口的均值 pandas.rolling_mean(arg, window, min_periods=None, fr ...
- 2018-2019-2 网络对抗技术 20165321 Exp5 MSF基础应用
1. 实践内容(3.5分) 1.1一个主动攻击实践: (1分) 首先攻击Windows XP: 在攻击机kali输入msfconsole进入控制台,依次输入以下指令: msf > use exp ...
- eslint的安装与使用
什么是 ESLint ESLint(中文站点)是一个开源的 JavaScript 代码检查工具,使用 Node.js 编写,由 Nicholas C. Zakas 于 2013 年 6 月创建.ESL ...
- django框架配置mysql数据库
django配置mysql数据库: 1.首先更改django项目文件中的settings.py的数据库配置 DATABASES = { 'default': { 'ENGINE': 'django.d ...
- 在Ubuntu中,vi命令编辑异常
在Ubuntu中,进入vi命令的编辑模式,发现按方向键不能移动光标,而是会输出ABCD,以及退格键也不能正常删除字符.这是由于Ubuntu预装的是vim-tiny,而我们需要使用的是vim-full, ...
- 实现一个自定义的ArrayList类,实现将原List中的每个数据都乘以10
1.首先自定义一个Operate接口,如下所示: public interface Operate { public Integer caozuo(Integer i); } 2.实现自定义的Arra ...
- RSA加解密算法以及密钥格式
RSA算法: 有个文章关于RSA原理讲的不错: https://blog.csdn.net/dbs1215/article/details/48953589 http://www.ruanyifeng ...
- 网络-04-端口号-linux端口详解大全--TCP注册端口号大全
# John Murphy <john.m.murphy&mci.com>afs3-fileserver 7000/tcp file server itselfafs3-files ...
- 阿里云 SSL 证书 总结
历时2天左右的证书上传部署,终于结束了! 因为公司要开发小程序,小程序部署到开发环境必须支持https证书行. 阿里云目前的证书还是比较多的额,大致分为2类,一类是支持单域名,一类是支持泛域名. 自己 ...