Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Flutter on Android blocks http:// with ERR_CLEARTEXT_NOT_PERMITTED

Errornet::ERR_CLEARTEXT_NOT_PERMITTED

Short answer

Android 9 (API 28) and newer block plain http traffic by default. The error means your app asked for an http:// address. The best fix is to use https. If you must use http, allow cleartext for that one domain in a network security config file and point the manifest at it.

  • Applies to Flutter 3.3x stable, Android 9 to 15, targetSdk 28 or higher
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find the URL that failed and check its scheme. Then look at what the manifest says about cleartext and network security config.

    grep -rn "http://" lib/
    grep -n "usesCleartextTraffic\|networkSecurityConfig" android/app/src/*/AndroidManifest.xml
  2. 2Match what you see, then jump to its fix

    1. 1The failing URL starts with http:// and the app's targetSdk is 28 or moreThe app targets API 28 or higher and uses an http:// URLFix
    2. 2A network security config exists, but the error remains for a subdomain or a different hostThe domain in the config does not match the host you callFix
    3. 3The manifest has usesCleartextTraffic="true" and the error still appearsandroid:usesCleartextTraffic is set but ignoredFix

What does the error look like?

  • net::ERR_CLEARTEXT_NOT_PERMITTED
  • Cleartext HTTP traffic to example.com not permitted

Cause 1 of 3

The app targets API 28 or higher and uses an http:// URL

1Check

Android turned cleartext support off by default starting with Android 9 (API 28). Apps that target that level or higher refuse http requests unless they opt in.

grep -rn "targetSdk" android/app/build.gradle* android/app/build.gradle.kts 2>/dev/null

2Fix

Switch the server and the URL to https. If you control the server, this is the real fix. If you cannot, opt in for that domain only with a network security config.

<!-- android/app/src/main/res/xml/network_security_config.xml -->
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">api.example.com</domain>
    </domain-config>
</network-security-config>

<!-- AndroidManifest.xml, on the <application> element -->
android:networkSecurityConfig="@xml/network_security_config"

3Verify

Rebuild the app (a hot reload does not pick up manifest changes) and repeat the request.

flutter run

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

The domain in the config does not match the host you call

1Check

A domain rule matches only that exact name unless includeSubdomains is true, and the most specific matching rule wins. Compare the host in your URL with each domain element.

cat android/app/src/main/res/xml/network_security_config.xml

2Fix

Add the exact host, or set includeSubdomains="true" on the parent domain.

<domain includeSubdomains="true">example.com</domain>

3Verify

Rebuild and call the same URL again.

flutter run

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

android:usesCleartextTraffic is set but ignored

1Check

On Android 7.0 (API 24) and above, this attribute is ignored when a network security config is present. It is also deprecated and ignored for apps that target API 38 or higher.

grep -n "usesCleartextTraffic\|networkSecurityConfig" android/app/src/*/AndroidManifest.xml

2Fix

Move the rule into the network security config file and remove reliance on the manifest attribute.

<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

3Verify

Rebuild, run on a device, and confirm the request goes through. Use base-config only for local testing, because it allows every domain.

flutter run

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Serve APIs over https and keep http:// URLs out of release builds.
  • If a dev server must use http, allow only that host in the config, not every domain.
  • Do not ship a base-config that permits cleartext for all domains.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Google Play says the app does not support 16 KB memory pages

check_elf_alignment.sh reports UNALIGNED for a library under lib/arm64-v8a

Google Play requires apps that target Android 15 or higher and ship native .so libraries to run on devices with 16 KB memory pages; from 1 February 2027 it will block updates that do not.

5 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.