办法一:
在AndroidManifest.xml的application中添加如下一条属性:android:usesCleartextTraffic=“true”
办法二:
在res/xml目录下新建xml文件,文件名为
network_security_config.xml
<?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>
之后在Manifest.xml文件中使用配置
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="@xml/network_security_config">
</application>
</manifest>