Flutter on Android blocks http:// with ERR_CLEARTEXT_NOT_PERMITTED
net::ERR_CLEARTEXT_NOT_PERMITTEDShort 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.
Fix it fast
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.xml2Match what you see, then jump to its fix
- 1
The 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
A 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
The manifest has usesCleartextTraffic="true" and the error still appearsandroid:usesCleartextTraffic is set but ignoredFix
- 1
What does the error look like?
net::ERR_CLEARTEXT_NOT_PERMITTEDCleartext 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/null2Fix
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 runConfirmed by developer.android.com
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.xml2Fix
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 runConfirmed by developer.android.com
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.xml2Fix
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 runConfirmed by developer.android.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
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 fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Gradle cannot create LibraryVariantBuilderImpl in a Flutter Android build
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl
This error appears when the Android Gradle plugin (AGP) cannot run in the Gradle or IDE you use.
3 causes, each with a fixMobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
Android install error: the package conflicts with an existing package of the same name
The package conflicts with an existing package by the same name
Android allows only one app per application ID, and an update must be signed with the same certificate as the installed version.
3 causes, each with a fixMobile apps
Android resource linking fails with resource android:attr/lStar not found
error: failed linking references.
The lStar attribute exists only from Android API 31.
2 causes, each with a fix