ionic capacitor working in browser and does not work in android

Here is how I resolved when the ionci capacitor is working in the browser and does not work in android.

9 times out of ten this is because you haven’t used https for the API feed. (Yes, I was using http as the API post URL)

http is disabled on android since a while back, unless you set up special security rules.

The rest of the time it’s a CORS issue.

What to do below:

Step 1. Create a file called network_security_config.xml in your project root  inside this path:

Then add these lines of code inside in as follow:

<?xml version="1.0" encoding="utf-8"?>

<base-config cleartextTrafficPermitted=”true”>

<trust-anchors> <certificates src=”system” /> <certificates src=”user” /> </trust-anchors>


<domain-config cleartextTrafficPermitted=”true”>

<domain-config cleartextTrafficPermitted="true">






Step 2.  Goto the app/src/main/AndroidManifest.xml file:

Then add this in the <application> section:





step 3. (Optional) Also in Your capacitor.config.json file add: set to true

cleartext?: true;


/** * Allow cleartext traffic in the Web View. * * On Android, all cleartext traffic is disabled by default as of API 28. * * This is intended for use with live-reload servers where unencrypted HTTP * traffic is often used. * * **This is not intended for use in production.** * * @since 1.5.0 * @default false

Then rebuild your apk: