[Error record] Android WebView reports an error (the web page cannot be opened at http://... The web page cannot be loaded because net::ERR_CLEARTEXT_NOT_PERMITTED )





1. Error record



Error message:

The page could not be opened
The page at http://… could not be loaded because net::ERR_CLEARTEXT_NOT_PERMITTED ;

insert image description here





Two, the solution



In Android 9.0 and above system versions , by default, the system prohibits applications from using unsafe plaintext traffic for network connections to improve user security.

This means that if the application tries to connect to an unsafe HTTP website, it will receive a net::ERR_CLEARTEXT_NOT_PERMITTED error; that is, when the WebView in the application tries to display an HTTP website, it will report a net::ERR_CLEARTEXT_NOT_PERMITTED error;

solution one

android:usesCleartextTraffic="true"The application node configuration attribute in the AndroidManifest.xml manifest file allows the application to use clear text traffic for network connection, which will reduce the security of the application;

	<application
	    android:usesCleartextTraffic="true" >
	</application>

solution two

Use the HTTPS protocol to encrypt HTTP websites to provide higher security protection;

If the website is developed by yourself and deployed on your own web server, you can use a free SSL/TLS certificate to enable HTTPS;

If you are using a third-party web service, you should contact the service provider to enable the SSL/TLS certificate, and then enable the HTTPS protocol;

Guess you like

Origin blog.csdn.net/han1202012/article/details/130205415