错误 网络请求时
// Android P系统限制了明文流量的网络请求 就会报这个错误
CLEARTEXT communication to xxx.xxx not permitted by network security policy
解决方法
- res目录下新建一个xml文件夹
- 新建 network_config.xml
<?xml version ="1.0" encoding ="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
- 添加到application中
<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:hardwareAccelerated="false"
android:configChanges="touchscreen"
android:networkSecurityConfig="@xml/network_config"
android:theme="@style/AppTheme">