The cause of the problem is:
Google said that in order to ensure the security of user data and devices, applications for the next-generation Android system (Android P) will require encrypted connections by default, which means that Android P will prohibit apps from using all unencrypted connections, so running Android No matter whether the Android device of the P system is receiving or sending traffic, it will not be able to transmit in plain text in the future. It needs to use the next-generation (Transport Layer Security) transport layer security protocol, while Android Nougat and Oreo will not be affected.
Solution:
1. Using the HTTPS protocol avoids unencrypted requests.
2. TargetSdkVersion drops below 27.
3. Add network security configuration xml.
Add a new xml directory under res, create a file named: urls_config.xml (the name can also be customized), the content is as follows:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
Add the following attributes to the application tag under the AndroidManifest.xml file of the APP:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xxxx.xxx">
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:networkSecurityConfig="@xml/urls_config"
...
>
</manifest>
4. Add the <code>android:usesCleartextTraffic attribute under the Application tag.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xxxx.xxx">
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...
>
</manifest>