一、问题原因:

根本原因是从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. python迭代-如何对迭代器做切片操作

    如何对迭代器做切片操作 问题举例 读取某个文件内容的100~300行内容,我们是否可以使用 类似列表切片的方式得到一个100~300行文件内容的生成器 分析 列表的切片操作其实是在重载方法__getI ...

  2. Pycharm中Python3连接Oracle

    一.环境配置:系统:win7.10 (64位)软件:1.Python3.7.2 (64位)2.instantclient-basic-windows.x64-11.2.0.4.0.zip(64位) - ...

  3. kali,parrot最新更新debain源

    deb http://mirrors.163.com/debian/ jessie main non-free contribdeb http://mirrors.163.com/debian/ je ...

  4. spring boot中使用@Async实现异步调用任务

    本篇文章主要介绍了spring boot中使用@Async实现异步调用任务,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟随小编过来看看吧 什么是“异步调用”? “异步调用”对应的是“同步 ...

  5. archlinux中安装Oracle12c的过程中遇到的问题

    INFO: : cannot find INFO: /usr/lib64/libpthread_nonshared.aINFO: INFO: genclntsh: Failed to link lib ...

  6. 使用Configuration Extensions读取配置

    使用Configuration Extensions读取配置 Configuration Extensions 是微软基于Configuration的扩展,能够很好的解析系统遇到各种配置文件,包括js ...

  7. python-列表与元组

    列表(List)     特性:         列表也是一种Sequence 类型        下标         能切片         可以存储任何类型的数据,每个元素是任意类型,可以存放任 ...

  8. 类与对象 && 继承

      以下是本人的对类与对象.继承的一些理解,如有错误之处万望谅解,如有朋友愿意指正,十分乐意,万分感谢!   类与对象     类与对象是学习编程的基础(大概吧),那么何为类?何为对象呢?   一.简 ...

  9. Oarcle之序列

    序列:是一种数据库对象,用来自动产生一组唯一的序号: 序列:是一种共享式的对象,多个用户可以共同使用序列中的序号. 创建序列 create sequence seq_emp_temp incremen ...

  10. pyCharm最新2018激活码

    本教程对jetbrains全系列可用例:IDEA.WebStorm.phpstorm.clion等 因公司的需求,需要做一个爬取最近上映的电影.列车号.航班号.机场.车站等信息,所以需要我做一个爬虫项 ...