我试图将图像发送到我的服务器。在我的虚拟设备上,一切正常,但是当我尝试在手机上安装应用程序时出现此错误:java.io.IOException:不允许x.x.x.x的明文HTTP通信。我的手机android版本:9 PKQ1我尝试在此Tuto https://medium.com/@imstudio/android-8-cleartext-http-traffic-not-permitted-73c1c9e3b803之后解决此问题但两种解决方案后的结果相同。我也尝试过这个Android 8: Cleartext HTTP traffic not permitted谢谢您的帮助。
它无法在您的移动设备上运行,因为:
您的移动设备支持android版本9(pie)。根据Android版本,由于Google设置的安全原因,您无法通过HTTP请求将请求发送到互联网。您只需要HTTPS。
解决方案:
将饼图的HTTP请求列入白名单的代码:
创建xml资源文件:network_security_configuration.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">google.com(your_domain)</domain>
</domain-config>
</network-security-config>
在Manifest.xml中:
<application
//add this below lines under your application tag.
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_configuration">