I have built a mobile app with React Native and Expo that consumes an API. When I create an APK and download the app on an Android device, I get the error:
Cannot connect to server try again later
when I try to login. But when I scan the QR code and open the app in Expo Go, it works fine. How can I fix this issue?
{
"expo": {
"name": "trackmobile",
"slug": "trackmobile",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "trackmobile",
"userInterfaceStyle": "automatic",
"newArchEnabled": true,
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"edgeToEdgeEnabled": true,
"package": "com.juno2025.trackmobile",
"usesCleartextTraffic": true,
"allowBackup": true,
"networkSecurityConfig": "./assets/xml/network_security_config.xml"
},
"web": {
"bundler": "metro",
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router",
[
"expo-splash-screen",
{
"image": "./assets/images/splash-icon.png",
"imageWidth": 200,
"resizeMode": "contain",
"backgroundColor": "#ffffff"
}
]
],
"experiments": {
"typedRoutes": true
},
"extra": {
"router": {},
"eas": {
"projectId": "2b8d5d6d-1b61-4f70-ace7-fc30b65b3a32"
}
}
}
}