How to run expo start with release-channels - react-native

I want to try running my react native app locally but against my staging and/or production server. I'm looking to do this by setting a release-channel variable when I run expo start. I hope this can test/foreshadow some performance in beta and production.
I tried the command expo start --release-channel staging and I got an error error: unknown option '--release-channel'
How can I set Constants.manifest.releaseChannel when I run expo start?

Environment variables don't exist explicitly, but you can utilize release channels to make that happen!
Say you have a workflow of releasing builds like this:
expo publish --release-channel staging-v1
For standalone apps:
Build your standalone app by running
expo build:ios --release-channel <your-channel>
expo build:android --release-channel <your-channel>
You can access the channel your release is published under with the releaseChannel field in the manifest object.
Constants.manifest.releaseChannel does NOT exist in dev mode. It does exist, however when you explicitly publish / build with it.
Here is a detailed description of this answer.

To those who also try to use environment within expo but for the web target,
My solution is to use cp to overwrite the prod configuration in prebuild script:
# fix --release-channel not available for web yet
cp -f src/config/env/staging.js src/config/env/prod.js
I also got tips from expo tips that the --release-channel feature is not available for web, this is the only way I have found so far.

react-native run-android --variant=release & react-native run-ios --configuration Release maybe would help :)

Related

Why does my Expo app run in Expo Go but not as a development build?

I've created a development build of an Expo app using EAS. Previously I would open the app in Expo Go by running npx expo start and scanning the Metro Bundler QR code.
Now, when I try to do the same thing, Expo Go asks whether I want to open the project in Expo Go or as a "Development Build". It works fine in Expo Go, but crashes immediately when I attempt to open the dev build. The error reads:
null is not an object (evaluating '_ReanimatedModule.default.createNode')
This error is suspiciously similar to one that I encountered earlier in development, which I resolved by downgrading to React Native version 0.69.6. I'm also encountering a second error that says "'main' has not been registered", but I suspect this is downstream of the first error.
I have the same issue when I try to run the app with npx expo start --dev-client.
Any ideas why I might be having this problem?
It sounds like you may have run expo prebuild (https://docs.expo.dev/workflow/prebuild/) which removes "main": "node_modules/expo/AppEntry.js", from app.json. Try to create a new expo app and look at it's app.json file.
When you run expo prebuild it changes a few things with your project (see "side effects" in the prebuild docs).
I'm actually working through some issues with that right now too. I thought I had to run prebuild but turns out I didn't have to. Ever since I ran it my app will not load via the dev-client way. I can however switch back to npx expo start (NOT npx expo start --dev-client, see the scripts section of app.json as that is also changed when prebuild is run).
Let me know if you are able to get your app to load after re-adding the main stuff to app.json.
Ps, are you by chance using react-native-google-mobile-ads?

Does Expo EAS Update require fetchUpdateAsync?

So I'm trying to implement Expo Updates for my managed, standalone build Expo App running SDK 46 following the instructions here: https://docs.expo.dev/eas-update/getting-started/
I'm not having much luck though.
The docs for setup state nothing more than:
npx expo install expo-updates
eas update:configure
eas build:configure
which just alter eas.json and app.json. Is that really all I should need? The docs for the package here: https://docs.expo.dev/versions/latest/sdk/updates/ talk about API methods like Updates.fetchUpdateAsync() but there's no example code. Do I need to implement that in my app somewhere?
Any advice much appreciated!

Impossible to update expo project inside Expo Go after switching to EAS Build

I have the need to run a project from Expo Go without being connected to PC. We are developing an app that require GPS and needs to be tested in open field.
Before EAS became the standard to create projects i used
expo build:android
ad this created not only the apk, but uploaded the project to my account and i was able to start it from Expo Go projects section just like the app was installed on phisical device. That worked also fo iOS and was a great testing feature.
After i moved to EAS Build
eas build -p android --profile preview --clear-cache
my project inside Expo Go does not update anymore and its stucked at sdk 44 even if now i'm working (and creating builds) with sdk 46.
I went through the official documentation many times but i don't get how to make the app start from Expo Go (project sction) as i did before. Maybe i'm missing some configuration.
Thank you all for any kind reply.
Have a good day.
EDIT
I found the solution to this problem and now my builds are working and uploading to Expo Go.
Check out this information: https://github.com/expo/fyi/blob/main/eas-build-archive.md
Basically EAS Updates will not bundle anything inside your .gitignore, in my case it needed specific config files. Did a quick test by taking them off the .gitignore and now it's working. Will move to GitHub SECRETS in the future.
Hope that helps.

Not going to release apk after expo eject

I created a new project at Expo, after which I was already building it using expo buildbut over time I needed to move away from Expo a little and execute an expo eject, and then continue development on regular React Native.
I ran into the following situation: I am trying to build an apk file with the ./gradlew assembleRelease command, but I get a debug build instead of release, I don’t understand why this is happening, I tried to follow the build instructions specifically for the release version - unsuccessfully.
I also tried to create a new project without using Expo - the whole scenario described above worked correctly and I got a release build of my application, and with all that, I compared the android/app/build.gradle files in these two projects and they are almost identical in terms of their configuration.
My main task and problem is to build the release version of the apk file and understand why, with different attempts to build, I only get the debug apk.

Build command in detox

Looking at this doc: https://github.com/wix/Detox/blob/master/docs/APIRef.Configuration.md
It says that the
Build command (either xcodebuild, react-native run-ios, etc...), will
be later available through detox CLI tool.
I'm trying to setup the build command to work with Android. Am I supposed to add react-native run-android to the build command? What do they mean by Detox CLI tool?
The build field is optional, and should contain whichever execution logic needed in order to have the .apk file set and ready in the path specified in binaryPath. You are more than welcome to refer to the Detox example project, which was set up as a reference exactly for these type of questions.
In any case, from the react-native CLI tool's help: react-native run-android = builds your app and starts it on a connected Android emulator or device. That makes it not very suitable, as we typically want to build the app, and have detox launch the emulator (optional) and install the app on the device(s), as needed.