Cleartext HTTP traffic to 192.168.1.106 not permitted https://blog.csdn.net/gengkui9897/article/details/82863966 When using httpurlconnection for HTTP request in Android P, the following exception will appear
W/system.err: java.io.ioexception: cleartext HTTP traffic to * * not permitted
Java.net.unknownserviceexception: cleartext communication * * not permitted by network security policy on Android P system devices, if the application uses HTTP network request of unencrypted plaintext traffic, it will cause the application unable to make network request, and HTTPS will not be affected. Similarly, if the application nested WebView, WebView can only use HTTPS requests
There are three ways to solve this problem
(1) App uses HTTPS request instead
(2) Targetsdkversion is below 27
(3) Change network security configuration
The first two methods are easy to understand and implement. The third method is to change the network security configuration
1. Create an XML folder under res folder, and then create a network_ security_ The content of the file is as follows:
<?xml version=”1.0″ encoding=”utf-8″?>
< network-security-config> & lt; base-config cleartextTrafficPermitted=”true” /> & lt;/ network-security-config> 2. Next, add the following attributes to the application tag in the androidmanifest.xml file:
< application … android:networkSecurityConfig= “@xml/network_ security_ config” … /> After that, the app will be able to access the network
——Update——
Method 4: in the & lt; application> Insert directly into the tag (thank you junbs for sharing)
android:usesCleartextTraffic="true"
Copyright notice: This is the original article of CSDN blogger “yuzijun”, which is in accordance with CC 4.0 by-sa copyright agreement. Please attach the link of original source and this notice. Link to the original text: https://blog.csdn.net/gengkui9897/article/details/82863966
Similar Posts:
- Python PIP installs scrapy with an error of twisted
- D/NetworkSecurityConfig: No Network Security Config specified, using platform default
- java.io.IOException: Server returned HTTP response code: 405 for URL:
- [Solved] Android O Error: Error inflating class android.webkit.WebView/For security reasons, WebView is not allowed in privileged processes
- Solve the security check error similar to error c4996: ‘scanf’: this function or variable may be unsafe in vs2019
- bash :startx command not found
- AttributeError: module ‘tensorflow’ has no attribute ‘Session’
- ERROR EPERM: operation not permitted, mkdir ‘C:\Users\Administrator\Desktop\text\nuxt\basic\…
- Completely solve MySQL error: 1030, ‘got error 28 from storage engine’
- linux pip3 is not found