Detached CRNA automated deployment

I have a detached CRNA that I have working with ExpoKit on Android and iOS. Configuration on both platforms points to my expo javascript bundle.

Right now, I am building a signed release .apk in Android Studio and sending my phone the .apk for install. It works, but…

I can’t figure out how the .env variables are supposed to work on a detached application. I’m using Windows for Android only right now - just to get one of them working to figure it all out.

I changed minor Android settings in app.json just to see if my changes get picked up. They do. I changed the androidStatusBar settings and I do see those changes.

My thought is that I can have an apk on my phone, run “exp publish” in Windows and restart the app on my phone to see those changes. Is that correct? Do I need to do something to reset the cache of the bundle? I feel like my phone wants to keep looking at the previous bundle (everything else is the same except for env variables values).

I do not change the version number of the bundle. Does that cause issues? I eventually will but I don’t need versioning to get it up and running.

The actual issue here is that I have a .env file, a file, a file and an env.production file. I have a script commands in the package.json that I am using to deploy:

"deploy:dev": "copy .env.production && exp publish --release-channel dev",
"deploy:prod": "copy .env.production && exp publish"

I thought something might have been messed up with my .env files. So, I set all of the files to my prod env variables (AWS). I run exp publish and restart the app. None of my data exists, so I think it works (since I should be pointing at a different database). I log out of the app, close it, restart it, and I log in. I should be hitting the prod AWS environment. But I’m not. I log in to my dev AWS account but my data isn’t saving. So, I know something changed but I’m not pointing to prod.

Does the app.json detach scheme or adnroidExpoViewUrl matter?

I’ve even tried closing and restarting the app a couple of times and deleting the app data/cache on the phone.


Hi! See my other reply – I suspect that Metro’s caching isn’t aware of changes in your .env files and isn’t running transforms again on the source files where you use the environment variables.

@dikaiosune I don’t want to hijack the other thread. What you said works. But it doesn’t look like that I can have multiple bundles at the same time with react-native-dotenv, at least not on separate release-channels. I pushed to a dev and prod release channel. I’m using the project page to load the different release channels via QR code. It’s looking like the last bundle I load is what’s loading for both of them.

I want to be able to scan the QR code from my project site and view changes made to my app (whether its a color change or an env variable change). That’s the idea behind expo, right?

Let me ask this a different way. If I have a signed/release apk from Android Studio, dropped onto and installed on my phone…

I have built the apk pointing to the default expo channel which was published using my dev env variables. If I make a small change to the bundle and publish (with --clear) to the default channel, should I be able to open the app on my phone and see those changes?

If it’s supposed to work that way, it is not. I changed the status bar color in app.json and pointed my env variables to a different server. Neither change is picked up by the installed apk on my phone.

And, using the project site, scanning the QR code for the dev and prod release-channel, things are finicky at best.

Is it something I’m not understanding? Am I supposed to build an release a new apk and install that? 99% of the application is in the expo bundle right? I should be able to push changes to my users via a new expo publish. But, either the device (I’ve cleared data in app btw) or native build gets in the way somehow. Thoughts?


@dmongit Some of the configuration fields in app.json are baked into the APK out of necessity – but as a rule of thumb, if you can edit the fields in app.json and see the changes in the Expo client from Google Play, then you can update those fields in a standalone app by just publishing.

Published JS updates also take two app launches to fetch, currently. When a standalone app is launched, it checks in the background to see if there are updates. If there’s an update, the app will download the update in the background. The update is used the second time the app is launched. (Launching means starting the app from a terminated state, not just foregrounding it.) That might affect your testing. We are thinking about ways to give developers more flexibility with update policies, but this is the current behavior on Android.

I have built the apk pointing to the default expo channel which was published using my dev env variables. If I make a small change to the bundle and publish (with --clear) to the default channel, should I be able to open the app on my phone and see those changes?

Yes, you should see the changes (with the caveat above about launching the app twice).

I am definitely fetching twice. I’ve tried deleting app data, uninstalling and re-installing, closing the app twice and many combinations of that. I do not see my changes no matter what I do.

The only time I’ve seen my changes is when I’ve deleted the android directory and detached again after making changes.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.