请求报错:CLEARTEXT communication to to 52.76.xx.xxx not permitted by network security policy
网上找资料发现版本较新的手机,系统版本限制使用http请求,必须要用https。
解决办法:
1、使用服务器和移动端都使用https
2、修改配置允许使用http明文通信
在manifests的application添加配置
android:networkSecurityConfig="@xml/network_security_config
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
同时在res资源文件xml中添加配置network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
cleartextTrafficPermitted 明文传输权限设置为true