First-time poster here, and I’m hoping someone in the community has seen this before.
I’ve been running some local API tests in an Android emulator (Pixel 6 image, API 33), and I’m hitting a strange situation where my Retrofit calls work fine on physical devices but consistently fail with a CLEARTEXT communication not permitted by network security policy error inside the emulator.
Here’s what I’ve tried so far:
Confirmed the local server is reachable on my host machine.
Added the correct android:usesCleartextTraffic="true" in the manifest.
Double-checked Network Security Config XML.
Tested on multiple emulator images (API 29, 31, 33).
Used adb reverse to map ports — still no luck.
Why I’m posting:
I know this is a fairly common topic for Android/DevOps workflows, but what’s confusing here is that the exact same build works fine on real hardware. I’m wondering if there’s some emulator-specific network setting I’m missing, or if this is a known quirk when testing local APIs.
I’ve uploaded my simplified test project here so it’s easier to reproduce:
https://modhello.com/tabs-pocket-edition
(it’s just a stripped-down example app + configs — no sensitive data, meant purely for debugging together)
My questions to the community:
Has anyone else experienced emulator-only network policy errors like this?
Are there any common pitfalls with emulator DNS/loopback I should double-check?
Is there a cleaner workaround than enabling cleartext traffic globally?
Thanks in advance — I’d really appreciate any tips or “oh yeah, I’ve been there” stories from others.
It feels like one of those small things that’s obvious… once you know it.
Environment details for reference:
Android Studio Giraffe | 2022.3.1 Patch 2
Emulator: Pixel 6 (API 33, Google Play image)
Backend: Local Node.js API running on localhost:3000
Top comments (0)