ERR_CLEARTEXT_NOT_PERMITTED - How to add usesCleartextTraffic to AndroidManifest.xml?

#1

What is the right way to add usesCleartextTraffic to Android manifest ? Code below should work but I get errors.

App.appendToConfig(`
    <edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
        <application android:usesCleartextTraffic="true"></application>
    </edit-config>
`);

=> Errors executing Cordova commands:

While adding platform Android to Cordova project:
Error: Unable to graft xml at selector “/manifest/application” from “C:\meteor\myapp.meteor\local\cordova-build\platforms\android\app\src\main\res\xml\config.xml” during config install
at ConfigFile_graft_child [as graft_child] (C:\Users\HXU\AppData\Local.meteor\packages\meteor-tool\1.8.1-beta.20\mt-os.windows.x86_64\dev_bundle\lib\node_modules\cordova-common\src\ConfigChanges\ConfigFile.js:122:19)
at PlatformMunger_apply_file_munge [as apply_file_munge]
.
.
.

#2

Are you using Meteor 1.8.1?

If yes, then you need to update the file attribute to this
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">

1 Like