android27以后建议使用https,如果没有特殊配置,直接使用http会报无法使用
解决方案:
res/xml下建立xml文件,名字随意,例如xxxxxxx,内容为:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
然后在AndroidManifest.xml的application中添加属性:
android:networkSecurityConfig="@xml/xxxxxxx"