expo: React Native expo API is not working in release.
Summary
I have developed a react native application using expo. I have tested application all along but when I am going to release it on Playstore. I got stuck in a issue. API is not working. I have tried multiple solutions. I already know about usesCleartextTraffic
and added that.
I decided to test it on android studio and after installing build on emulator checked the logs it is giving the following error.
403 error.
So then I removed CORS from backend API but there is no change. I don’t know why is that issue.
I am very frustrated about this. If anyone can help me about this Thanks!
Managed or bare workflow?
bare
What platform(s) does this occur on?
Android
Package versions
No response
Environment
expo-env-info 1.0.5 environment info:
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 18.17.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
SDKs:
Android SDK:
API Levels: 31, 32, 33
Build Tools: 29.0.2, 30.0.2, 30.0.3, 33.0.0, 33.0.2
System Images: android-33 | Google APIs Intel x86_64 Atom
IDEs:
Android Studio: AI-222.4459.24.2221.9971841
npmPackages:
expo: ^49.0.13 => 49.0.16
react: 18.2.0 => 18.2.0
react-native: 0.72.6 => 0.72.6
Expo Workflow: bare
Reproducible demo
App.json as follow
{ "expo": { "name": "Jobs Australia", "slug": "jobsapplication", "plugins": [ "@react-native-google-signin/google-signin", "@react-native-firebase/app", "@react-native-firebase/auth", [ "@stripe/stripe-react-native", { "merchantIdentifier": "", "enableGooglePay": false } ], [ "expo-build-properties", { "android": { "usesCleartextTraffic": true } } ] ], "version": "1.0.0", "orientation": "portrait", "icon": "./assets/icon.png", "userInterfaceStyle": "light", "splash": { "image": "./assets/splash.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "assetBundlePatterns": [ "**/*" ], "ios": { "supportsTablet": true, "bundleIdentifier": "com.anonymous.jobsApplication", "googleServicesFile": "./GoogleService-Info.plist" }, "android": { "adaptiveIcon": { "foregroundImage": "./assets/anImageThat.png", "backgroundColor": "#ffffff" }, "googleServicesFile": "./google-services.json", "package": "com.anonymous.jobsApplication", "versionCode": 1 }, "packagerOpts": { "sourceExts": [ "js", "json", "ts", "tsx", "jsx", "vue"] }, "web": { "favicon": "./assets/favicon.png" }, "extra": { "eas": { "projectId": "7060e1ae-b62b-4807-9345-9f3a2baf0afc" } }, "owner": "tayyabrana" }, "react-native-google-mobile-ads": { "android_app_id": "ca-app-pub-3940256099942544~3347511713", "ios_app_id": "ca-app-pub-3940256099942544~3347511713" } }
eas.json
{ "cli": { "version": ">= 5.1.0" }, "build": { "development": { "developmentClient": true, "distribution": "internal" }, "preview": { "android": { "buildType": "apk" } }, "production": {} }, "submit": { "production": {} } }
Stacktrace (if a crash is involved)
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 35 (2 by maintainers)
I had the same problem where
API
protocol isHTTP
. The solution for me was:1. Install:
npx expo install expo-build-properties
2. Add
usesCleartextTraffic: true
toapp.json
:{ "expo": { .... "plugins": [ [ "expo-build-properties", { "android": { "usesCleartextTraffic": true } } ] ] }
Also, for testing purposes, I added an extra
HTTPS API
call (https://jsonplaceholder.typicode.com/todos/1) that also works as expected.I also had a same problem after upgrading project from expo 47 to 50. Http & https requests were being failed. Below solutions worked as mentioned by many people
npx expo install expo-build-properties
{ “expo”: { … “plugins”: [ [ “expo-build-properties”, { “android”: { “usesCleartextTraffic”: true } } ] ] }
Hi - I’m going to close this. If anyone can provide a minimal project that reproduces the problem, I’ll reopen.
I am having the same problem. I can see that android:usesCleartextTraffic=“true” is present in debug manifest, but not on main (i tried to manually put there but nothing). “axios”: “^1.6.2”, “expo”: “^49.0.21”, “expo-build-properties”: “~0.8.3”,
Also, if your build is working locally but not with EAS, I would take a look at your environment variables
I was having the same issue. Following docu at expo build properties : I did the following:
npx expo install expo-build-properties
and then adding:
Using apk-tools I inspected the generated apk file. It had correctly usesCleartextTraffic flag in AndroidManifest.xml And my app also worked fine. Hope it helps others.
Thank You guys
worked for me, thanks a lot
I just made a try catch and it worked Maybe it would not solve your problem, but mine worked well
below the example (just try it):
@rafakwolf - we provide best-effort support on github issues with our small team, and sometimes issue reports take some time get to them. we prioritize actionable issues that provide the information we request in the issue template. the amount of time that an issue has been open for doesn’t change the criteria for what is required when reporting an issue.
we ask for a minimal reproducible example in the issue report template, i’ll have to double check why the issue wasn’t automatically closed by our bot for not fitting that criteria. here is what we usually print along with it:
as @alanjhughes pointed out, we’d be happy to help you but we need your help in the form of a minimal reproducible example in order to do so
There is nothing expo is doing to have an affect on your network requests. It’s the same as in a bare react native. I cannot investigate an issue unless I can reproduce it. I am happy to look into it if you can provide me a reliable way to recreate the issue.
@Dalu26 thank you, indeed, building it locally works fine.
@Develens no success around here, here’s what I did:
To be honest I don’t know what else to do
my packages
app.json
eas file
@alanjhughes