一、问题原因:

根本原因是从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. Xamarin.Forms 未能找到路径“x:\platforms”的一部分

    https://stackoverflow.com/questions/45500269/xamarin-android-common-targets-error-could-not-find-a-p ...

  2. 关于11G DataGuard 日志传输的案例

    案例探讨 在归档和非归档模式下,配置参数log_archive_dest_2后,DG的备库是否传输日志. 案例环境描述 本次环境如下,一套RAC+单机DG,然后从DG还原出来一个单独的测试库A,测试库 ...

  3. nuxt 2

    原文出处: 

  4. python编写接口初识一

    python编写接口这里用到的是他一个比较轻量级的框架 flask #!/usr/bin/python # -*- coding: UTF-8 -*- import flask,json server ...

  5. URLs ...

    各浏览器对ES6的支持 https://blog.csdn.net/lpw_cn/article/details/84789183 http://kangax.github.io/compat-tab ...

  6. 写好shell脚本

    转载自https://mp.weixin.qq.com/s/f3xDHZ7dCQr7sHJ9KDvuyQ 1.提供--help标记 安装在系统上的二进制文件通常带有man帮助文档,但对于脚本来说就不一 ...

  7. Excel坐标自动在AutoCad绘图_4

    众所周知,Excel对数据处理的功能非常强大,它可以进行数据处理.统计分析已经辅助决策的操作,该软件已经渗透到各个领域.作为一个测绘人,GISer, 也经常利用excel完成一些测量表格的自动化计算, ...

  8. ORA-01589解决

    错误展现如下: sqlplus /nolog SQL> conne /as sysdbaConnected.SQL> shutdown abortORACLE instance shut ...

  9. TTL和COMS电平匹配以及电平转换的方法

    一.TTL TTL集成电路的主要型式为晶体管-晶体管逻辑门(transistor-transistor logic gate),TTL大部分都采用5V电源.1.输出高电平Uoh和输出低电平UolUoh ...

  10. MIUI系统如何获取ROOT权限

    MIUI系统有么好方法启用了Root超级权限?各位都清楚,Android手机有Root超级权限,一旦手机启用了root相关权限,就能够实现更多的功能,举例子,各位公司的营销部门的同事,使用大多数营销工 ...