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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more