一、问题原因:

根本原因是从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. 在Linux下如何使用openssl生成RSA公钥和私钥对

    在<Java实现RSA密钥对并在加解密.加签验签中应用的实例>中,我们有用Java代码生成RSA密钥对,其实在Linux操作系统中,用openssl也是很容易生成密钥对的. 一.如果在ub ...

  2. U面经Prepare: Print Binary Tree With No Two Nodes Share The Same Column

    Give a binary tree, elegantly print it so that no two tree nodes share the same column. Requirement: ...

  3. c#中WebApi开发遇到的坑

    一.如何新建一个webApi项目 打开VS→找到解决方案→新建项目→类库或web应用程序→选择空的WebApi项目→在Global.asax文件的Application_Start方法中注册WebAp ...

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

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

  5. 如何共享联盟cookie

    接上一篇阿里妈妈账号登录状态如何长时间保存 既然我们获取到了cookie, 如果有多个程序都要使用到联盟帐号的时候, 如果不共享cookie, 那么每个程序都需要登录一次, 真的很浪费资源. 如何共享 ...

  6. window xshell 连接本地ubuntu虚拟机

    先设置VMware 虚拟机的连接属性 1.桥接,利用真实网卡  设置和window 同一个网段就可以直接通信 2.hostnoly是通过vm8(查看你的所有网络连接) 只能和主机联系 设置和vm8同一 ...

  7. Yii2.0 上使用 redis

    1. 通过composer进行安装,到项目根目录cmd运行 php composer.phar require --prefer-dist yiisoft/yii2-redis或者添加 "y ...

  8. (cvpr2019 ) Better Version of SRMD

    SRMD的内容上篇,已经介绍,本文主要介绍SRMD的升级版,解决SRMD的诸多问题, 并进行模拟实验. 进行双三次差值(bicubic)===>对应matlab imresize() %% re ...

  9. vue配置手机通过IP访问电脑开发环境

    vue配置手机通过IP访问电脑开发环境config/index.js// Various Dev Server settings host: '0.0.0.0', // can be overwrit ...

  10. SQL server 删除日志文件 秒删

    直接执行 USE [库名称]GOALTER DATABASE [库名称] SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE  [库名称] SET REC ...