前言
因为现在高版本android系统强制要求网络请求必须是https,如果使用的是http请求,则会导致网络请求不可用,这个时候就需要添加权限声明了
添加xml权限声明
-
在res文件夹下添加xml文件夹
-
新建文件名为network_security_config的xml文件
3.声明权限
<network-security-config>
<base-config cleartextTrafficPermitted="true"></base-config>
</network-security-config>
4.在AndroidManifest的application里中注册该权限
android:networkSecurityConfig="@xml/network_security_config"

5.搞定收工
网友评论