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,需要选择两个,在钥匙串访问的私钥和证书.
随机推荐
- Linux系统常用升级的基础包
Linux系统常用升级的基础包 yum -y install lrzsz gcc gcc-c++ make flex autoconf automake vixie-cron libjpeg libj ...
- 网页静态化解决方案-Freemarker demo+语法
1.网页静态化技术Freemarker 1.1为什么要使用网页静态化技术 网页静态化解决方案在实际开发中运用比较多,例如新闻网站,门户网站中的新闻频道或者是文章类的频道. 对于电商网站的商品详细页来说 ...
- arcgis 画图工具
arcgis 4.x系列JavaScript API在4.4及以前的版本对画图工具(Draw)是不支持的,自4.5版本后才提供Draw的类.相关连接:https://developers.arcgis ...
- Oracle中row_number()、rank()、dense_rank() 的区别
link:https://www.cnblogs.com/qiuting/p/7880500.html
- Angular4 管道
- 记录tiny6410 使用linux-2.6.28.6内核遇到starting kernel...的问题
1\问题的解决主要是参考了tiny210相同的问题 2\/home/suxuandong/Documents/computer/linux_kernel/tiny6410/linux-2.6.28.6 ...
- Class打包成jar
Class打包成jar 现在我的文件夹的目录在: C:\Users\linsenq\Desktop\cglibjar 我要把位于这个目录下的所有文件夹以及这个文件夹下的.class文件打成jar包 第 ...
- mui返回上个页面并刷新数据
转 https://blog.csdn.net/mercedescc/article/details/82769264 今天写项目遇到个问题,就是B页面支付操作完成以后,点击返回按钮要到A页面,此时A ...
- Caused by: java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFCell.setEncoding(S)V
java.lang.reflect.InvocationTargetException. Coused by : java.lang.NoSuchMethodError:这个异常是找不到方法,但是如 ...
- 用Python实现一个词频统计(词云+图)
第一步:首先需要安装工具python 第二步:在电脑cmd后台下载安装如下工具: (有一些是安装好python电脑自带有哦) 有一些会出现一种情况就是安装不了词云展示库 有下面解决方法,需看请复制链接 ...