skip to Main Content

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


  1. Http request doesn’t work in the latest android updates. So you have to update your AndroidManifest.xml

        <uses-permission android:name="android.permission.INTERNET" />
    
        <application
           android:usesCleartextTraffic="true"> // Update here 
        </application>
    

    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.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search