android – Ionic Native HTTP does not work for Anroid 9 (Pie) and up?-ThrowExceptions

Exception or error:

I’ve created an app that connects successfully to our server using Ionic Native HTTP, testing it with Samsung Galaxy J7 Prime OS version Marshmallow and several others that were not yet under Android Pie. For some reason, when I tested it with a device under Android Pie, it won’t work anymore and I’m receiving CORS policy issues. Has anybody encountered a similar issue? Is there a workaround for this? Unfortunately, modifications within the server config is not an option. I’ve also read some solutions about proxy but am not sure how to implement them.

cordova-plugin-advanced-http: 2.1.1
ionic-native/http: 5.8.0

How to solve:

Android P requires HTTPS by default. What this means is that if you are using unencrypted HTTP requests in your app, the app will work fine in all lower versions than Android P.

To avoid this security exception, try below changes in your app code.

In AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config"
                    ... >

and in res/xml add file named : network_security_config.xml


<?xml version="1.0" encoding="utf-8"?>
    <domain-config cleartextTrafficPermitted="true">
        //  Add host of your download URL in below line. 
        //   ie. if url is  ""
        //   then just add ""
        <domain includeSubdomains="true"></domain>


To solve that problem, you should make changes to the config.xml file.

First thing you need to change is ‘widget’ tag, it should look similar to this one:

<widget id="" version="2.2.2" xmlns="" 

After that, inside of platform where name=’android’, you should add this code:

<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
    <application android:usesCleartextTraffic="true" />

After that you can run rebuild the application.

Leave a Reply

Your email address will not be published. Required fields are marked *