DEV Community

Dênis Mendes
Dênis Mendes

Posted on

ERR_CLEARTEXT_NOT_PERMITTED from Android WebView

If you're seeing that kind of error: ERR_CLEARTEXT_NOT_PERMITTED when trying to open a localhost url into Webview in Android then you need to allow that to be possible opening, here's how to do it:

You need to create that xml file into res/xml:

<?xml version="1.0" encoding="utf-8"?> <network-security-config> <base-config cleartextTrafficPermitted="true"> <trust-anchors> <certificates src="system" /> </trust-anchors> </base-config> </network-security-config> 
Enter fullscreen mode Exit fullscreen mode

and after that in AndroidManifest.xml you need to add:

 <application ... android:networkSecurityConfig="@xml/network_security_config" 
Enter fullscreen mode Exit fullscreen mode

It's done.

Top comments (0)