Tuesday, October 8, 2019

FIX Cleartext HTTP traffic not permitted




Some time ago I found a little problem when building android applications using the framework Ionic 3 and Cordova version 9.
When using the file transfer plugin to upload files to the server, the error message appears  Cleartext HTTP traffic not permitted . This message appears when I run the application on devices with Android Pie (version 9). When an application communicates with a server using clear text network traffic such as HTTP, this can increase the risk because the data is not Config in the Android Manifest. Open the network_security_config.xml file located in the resources / xml / folder . Add your domain server, for example as below

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">192.168.99.183</domain>
        <domain includeSubdomains="true">10.0.2.2</domain>
    </domain-config>
</network-security-config>

Note: IP address 192.168.99.183 above is the local PC server domain that I use (localhost) if I want to run applications with real devices in a network between the PC and the device. The IP address 10.0.2.2 is the PC's local server domain when using an emulator to run applications. You can replace the domain above with the domain address of the server you are using. For more details about traffic cleartext or installation of certificates to avoid being hit by man-in-the-middle attacks. Please read the documentation here Configuring network security

Advertiser