Why am I seeing net::ERR_CLEARTEXT_NOT_PERMITTED errors after upgrading to Cordova Android 8?
android, cordova
Solution
The default API level in the Cordova Android platform has been upgraded. On an Android 9 device, clear text communication is now disabled by default.
To allow clear text communication again, set the `android:usesCleartextTraffic` on your `application` tag to `true`:
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
As noted in the comments, if you have not defined the `android` XML namespace previously, you will receive an `error: unbound prefix` during build. This indicates that you need to add it to your `widget` tag in the same `config.xml`, like so:
<widget id="you-app-id" version="1.2.3"
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
Problem
After upgrading to Cordova Android 8.0, I am seeing `net::ERR_CLEARTEXT_NOT_PERMITTED` errors when trying to connect to `http://` targets. Why is that and how can I resolve this?