一、问题原因:

根本原因是从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的更多相关文章

  1. 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 ...

  2. eclipse连接远程Hadoop报错,Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。

    eclipse连接远程Hadoop报错,Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接.全部报错信息如下: Exception in thread & ...

  3. 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 ...

  4. Caused by: java.io.IOException: Filesystem closed的处理

    org.apache.hadoop.hive.ql.metadata.HiveException: Unable to rename output from: hdfs://nameservice/u ...

  5. Caused by: java.io.IOException: 你的主机中的软件中止了一个已建立的连接。

    org.apache.catalina.connector.ClientAbortException: java.io.IOException: 你的主机中的软件中止了一个已建立的连接. at org ...

  6. 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 ...

  7. Caused by: java.io.IOException: 您的主机中的软件中止了一个已建立的连接。

    异常详情 2017-07-16 10:55:26,218 ERROR [500.jsp] - java.io.IOException: 你的主机中的软件中止了一个已建立的连接. org.apache. ...

  8. 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 ...

  9. Push notification - Caused by java.io.IOException toDerInputStream rejects tag

    苹果推送 : 文件不是P12文件当生成一个P12,需要选择两个,在钥匙串访问的私钥和证书.

随机推荐

  1. Azure基础(二)- 核心云服务 - Azure简介

    Azure fundamentals - Core Cloud Services - Introduction to Azure Learn what Microsoft Azure is and h ...

  2. mac电脑安装wxPython2.8.12.1不成功怎么办 , Could not find a version that satisfies the requirement 2.8.12.1

    目的:robotframe-ride用于接口测试 遇到的问题: 1.mac终端pip安装robotframework-ride后 pip install robotframework-ride (pi ...

  3. linux 查看是否安装了MySQL

    yum 安装mysql      yum -y install mysql-server ------------------------------------------------------- ...

  4. 干货 | LIDAR、ToF相机、双目相机如何科学选择?

    点击"计算机视觉life"关注,置顶更快接收消息! 本文阅读时间约5分钟 本文翻译自卡内基梅隆大学 Chris asteroid 三维视觉技术的选择 传感器参数及定义 LIDAR ...

  5. Rsync数据同步工具

                                        Rsync数据同步工具 什么是Rsync? Rsync是一款开源的.快速的.多功能的,可以实现全量及增量的本地或原程数据同步备份 ...

  6. TCP连接状态管理

    tcp 连接过程 tcp 状态机

  7. Sitecore8.2 GeoIP - 在8.2的引擎盖下发生了什么?

    访客互动 - 访客会话的开始 访问者访问Sitecore网站,这被视为一种新的互动.Sitecore对交互的定义是“......联系人与品牌联系的任何一点,无论是在线还是离线”.在我们的例子中,这是网 ...

  8. 使用gulp构建一个项目

    gulp是前端开发过程中自动构建项目的工具,相同作用的还有grunt.构建工具依靠插件能够自动监测文件变化以及完成js/sass/less/html/image/css/coffee等文件的语法检查. ...

  9. Genymotion-Android模拟器提示"Unable to connect to the Genymotion server. Please check your Internet connection."解决方法

    昨天刚装的Genymotion,昨晚还用得好好的. 今晚开机,重新打开Genymotion,却提示:"Unable to connect to the Genymotion server. ...

  10. JavaScript--图片放大镜

    图片放大镜的原理: 两张相同的图片img1和img2,img1上有一个#dd的div,通过鼠标移动dd,根据dd区域内的图片,来裁剪img2的图片,并将img2的图片放大,显示出来 关键词:img1坐 ...