不允许对server.com的明文HTTP流量 [英] Cleartext http traffic to server.com not permitted
问题描述
我的代码在android KitKat上运行,但是在Pie中运行时却出现io异常
My code is working on android KitKat but it when running it in Pie gives io exception
不允许对server.com的明文http流量
Cleartext http traffic to server.com not permitted
我正在使用凌空拨打服务器.
I'm using volley to make server calls.
推荐答案
第一步是了解为什么 Google强制您使用HTTPS.您可以在开发人员页面上阅读更多有关此内容的信息.
First step is understanding why Google enforces you to use HTTPS. You can read more about it on the developers page.
关于解决方法,有两种选择:
As for how to fix it, there are two options:
1)使用HTTPS!
1) Use HTTPS!
2)在您的XML文件夹中创建一个名为security_config.xml
的新文件,并添加以下文件:
2) Create a new file in your XML folder named security_config.xml
and add this:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
然后在清单文件中添加此
then in your Manifest file add this
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="@xml/security_config">
</application>
</manifest>
出于明显的原因,不建议第二点!
For obvious reasons, the second point is not recommended!
这篇关于不允许对server.com的明文HTTP流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!