Problem Description:
The following error occurs on Android9.0(SDK version 28), not on Android9.0(SDK version 28), using the network framework is OKHttp
Java.net.UnknownServiceException: CLEARTEXT communication to xxx.xxx.com (domain name) is not permitted by the network security policy
Solutions:
1. Change the APP to HTTPS request (this requires background assistance and HTTPS certificate, which is easy to solve)
2. TargetSdkVersion drops to 27 or below
3, the application in the listing file node add < application android: usesCleartextTraffic = “true” > original default is true, but change the default value to false in android 9.0, Therefore, manually setting the configuration to true resolves the problem of restricted plaintext transmission
Create an XML folder and create network_security_config.xml
<? xml version="1.0" encoding="utf-8"? ><network-security-config> <base-config cleartextTrafficPermitted="true" /></network-security-config>Copy the code
Under the listing file application node add < application android: networkSecurityConfig = “@ XML/network_security_config” >
Expanded description: