I am working on a react native app which works fine when i build it using the metro bundler however when I generate a signed APK I cant login as it show Network error. What could be the reason for this behavior?
I logged the responses and usually axios throws a network error incase of actual network loss however the build APK always throws a network error.
2
Answers
Http request doesn’t work in the latest android updates. So you have to update your AndroidManifest.xml
Also Check for CORS (Cross-Origin Resource Sharing)issue.
If your app communicates with a server that enforces CORS policies, ensure that the server allows requests from the domain where your APK is hosted. This is usually not an issue during development but can be in production.
When you build in release mode, non-HTTPS requests are blocked by default. To get around this, you need to make some modifications to your AndroidManifest.xml file.
https://reactnative.dev/docs/next/network https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic