问题描述
除了安卓9以外其他版本都能都联网,debug版本也能够联网,所以问题就出在安卓9release打包问题上了。实际上安卓9以后对于http请求的配置会类似于ios,需要手动配置联网设置
解决方案
在src/main/res中创建xml文件,并创建network_security_config.xml文件
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
在src/main/androidManifest.xml 添加
android:networkSecurityConfig="@xml/network_security_config"