Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug/Build/Deploy Expo app locally without EAS/CI or Expo Go #1300

Closed
martin-braun opened this issue Aug 22, 2022 · 18 comments
Closed

Debug/Build/Deploy Expo app locally without EAS/CI or Expo Go #1300

martin-braun opened this issue Aug 22, 2022 · 18 comments
Assignees
Labels
enhancement New feature or request

Comments

@martin-braun
Copy link

martin-braun commented Aug 22, 2022

Summary

I assume this should be a mistake. When running local builds on my own infrastructure, there is no need to ask for authentication. This is very important, because it ensures that EAS can even function in a local environment when the Expo service is not available.

Environment

  "dependencies": {
    "@expo/webpack-config": "^0.17.0",
    "expo": "~46.0.8",
    "expo-status-bar": "~1.4.0",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-native": "0.69.4",
    "react-native-dotenv": "^3.3.1",
    "react-native-web": "~0.18.7"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "cross-env": "^7.0.3",
    "eas-cli": "^1.0.0",
    "expo-cli": "^6.0.5",
    "npm-check-updates": "^16.0.5",
    "shx": "^0.3.4"
  },

Reproducible demo or steps to reproduce from a blank project

npx create-expo-app my-app
cd my-app
npm i eas-cli -D
eas build:configure # <- here it asks for credentials
eas build --platform android --local # <- here it asks for credentials as well
@martin-braun martin-braun added the needs review Issue is ready to be reviewed by a maintainer label Aug 22, 2022
@dsokal dsokal added needs more info and removed needs review Issue is ready to be reviewed by a maintainer labels Aug 23, 2022
@dsokal
Copy link
Contributor

dsokal commented Aug 23, 2022

Hi @martin-braun,

Could you please clarify what's the issue? Put in other words, what credentials EAS CLI is exactly expecting you to pass?

@dsokal dsokal self-assigned this Aug 23, 2022
@martin-braun
Copy link
Author

martin-braun commented Aug 23, 2022

Hi @dsokal. My goal is to be able to not use the CI of Expo altogether and just benefit from the build tools. I learned about prebuilding my projects, but trying to run my project directly from Android Studio as debug APK on my physical device gives me "Unable to load script. Make sure you're either running Metro or your bundle is packaged correctly for release".

Trying to run my project with expo run:android will result in "CommandError: Couldn't open Android app with activity "my-app://expo-development-client/?url=http%3A%2F%2F192.168.67.245%3A8081" on device "Pixel_3a".
The app might not be installed, try installing it with: npx expo run:android -d Pixel_3a"

I tried the command above to solve it, same result.

Using eas build --platform android --local will still ask me for expo.dev credentials. If I give them it will create a project on your server and link the project ID.

Look, I understand that Expo is very slick and customer-friendly with your CI tightly integrated, but a service can never remain forever. It also feels weird that I cannot opt-out of the server dependency at any time. I know that I can ditch Expo and use RN directly, but I was hoping that I can build an app with the slick Expo tool chain with peace in mind, that I can always fall back to do truly local builds without any remote dependency.

If this means that I have to eject from Expo, it defeats the purpose and I rather move to RN directly which will give me more opportunities like building for Windows and macOS.

@dsokal dsokal added enhancement New feature or request and removed needs more info labels Aug 23, 2022
@dsokal
Copy link
Contributor

dsokal commented Aug 23, 2022

Your concerns sound reasonable. We'll try to address them soon.

@martin-braun
Copy link
Author

martin-braun commented Aug 23, 2022

@dsokal Thanks a lot. Good news though. I checked the documentations of ReactNative regarding my error above. When I run npx react-native start before debugging the APK in Android Studio, the build will work and even watch my JavaScript files for any changes. So I think I solved my issue/concern already and I want to share how local building works without the expo.dev CI being involved.

I can just run npx expo prebuild && npx react-native run-android or npx expo prebuild && npx react-native run-ios to debug without Expo Go. I can then use npx react-native bundle ... to bundle the JavaScript properly for release builds. It get's the job done.

So luckily I know that I can peacefully use Expo and its CI and have always the option to fall back to local building, as long as I keep the signing local as you mentioned.

Will my configuration be compatible with expo plugins when I decide to build locally? I.e. will expo prebuild add everything that I need to bypass Expo CI in all circumstances?

@martin-braun martin-braun changed the title EAS asks for authentication despite the fact that I want to initiate a local build Debug/Build Expo app locally without EAS/CI or Expo Go Aug 23, 2022
@martin-braun martin-braun changed the title Debug/Build Expo app locally without EAS/CI or Expo Go Debug/Build/Deploy Expo app locally without EAS/CI or Expo Go Aug 23, 2022
@dsokal
Copy link
Contributor

dsokal commented Aug 23, 2022

I don't know if I fully understand your message but for what it's worth, you need to use react-native start because simulator/emulator builds don't bundle your JS code.
As for the other question - I think expo-cli / react-native cli should be pretty much compatible with each other.

@trevorwang
Copy link

trevorwang commented Jun 5, 2023

Hi @dsokal
Is there any way to run eas build --platform android --local without expo credentials
EAS CI is great service but we don't have public network access due to company's policy

Proceeding with outdated version.

[Network] request to https://api.expo.dev/graphql failed, reason: read ECONNRESET
    Error: GraphQL request failed.

@gediminastub
Copy link

I would like to know that too. Thanks!

@Youngermaster
Copy link

@trevorwang To be able to build the project in Android without EAS, I used these commands:

# To generate all the Android and IOS files
npx expo prebuild

# Make sure to connect your device or to run your Emulator
npx react-native run-android --mode="release"

# If you want to sign the APK and publish to Google Play Store.
npx react-native build-android --mode=release

Remember to follow up the React Native Documentation to sign the APK and publish to Google Play Store.

@trevorwang
Copy link

@Youngermaster Many thanks. Will try later.

@Youngermaster
Copy link

@trevorwang You are welcome, I hope that fix your issue, It worked for my First App in React Native with Expo, I'll deploy tomorrow if everything goes right (If Google Play accepts my App).

@HonestElf
Copy link

Hi!
I managed to create andorid standalone release apk by launching "npx expo prebuild && cd ../andorid && ./gradlew assembleRelease"
But is there any way to create ios simulator build (archive) without eas and without paid Apple Developer Account?

@manickam1999
Copy link

npx expo prebuild && npx react-native run-android
Throws me the error below. I am trying to build a debug standalone expo app
[Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release](https://stackoverflow.com/questions/55441230/unable-to-load-script-make-sure-you-are-either-running-a-metro-server-or-that-yo)

@johhansantana
Copy link

@trevorwang To be able to build the project in Android without EAS, I used these commands:

# To generate all the Android and IOS files
npx expo prebuild

# Make sure to connect your device or to run your Emulator
npx react-native run-android --mode="release"

# If you want to sign the APK and publish to Google Play Store.
npx react-native build-android --mode=release

Remember to follow up the React Native Documentation to sign the APK and publish to Google Play Store.

For anyone trying to just build an APK you can do the prebuild command and after:

cd android && ./gradlew assembleRelease

@teesloane
Copy link

Hi! Sorry to dig up an old thread. I just want to confirm — is there no way to run a build locally via eas, for example:

eas build --local --profile development-detox --platform ios

Without having to login?

@JeremyXXXuuu
Copy link

JeremyXXXuuu commented Apr 23, 2024

@trevorwang

Hi! Sorry to dig up an old thread. I just want to confirm — is there no way to run a build locally via eas, for example:
eas build --local --profile development-detox --platform ios
Without having to login?

EAS seems need login every time. There is a workaround for me to build for ios device locally,
expo prebuild + expo run:ios --configuration Release --device [your device/simulator Identifier]

@undefine-man
Copy link

undefine-man commented Jun 22, 2024

For android, you can use expo prebuild -p android to generate android project structure.
Then use npx react-native build-android --interative to build the app. --interative flag will scan the gradle tasks and you can choose .aab or .apk as output file.
Use expo to build the final app is optional choose, you can build the app use gradlewreact-native command or expo command.
Upper level command call bottom level command. expo and react-native are upper level command, they all need to call gradlew to build the app.

@shawnmclean
Copy link

shawnmclean commented Jul 1, 2024

What are you guys doing in your CI for the build step?

Expo comes with the default

"build": "expo export --output-dir ./build --platform all",

Does it make sense to swap this to expo prebuild? That way I truly build the intended output?

What purpose does the export serve if I'm not using expo to serve up web?

Edit: expo build seems to run the prebuild anyways.

@ajithv11
Copy link

ajithv11 commented Sep 19, 2024

@Youngermaster

Your solution works


# To generate all the Android and IOS files
npx expo prebuild

# Make sure to connect your device or to run your Emulator
npx react-native run-android --mode="release"

# If you want to sign the APK and publish to Google Play Store.
npx react-native build-android --mode=release

But when I tried to run npx react-native start , it didn't work
The error occured is error: Error: Unable to resolve module @/store/store on line import { store } from "@/store/store";
If I change the code to import { store } from "../store/store"; It works.
But I need @ to work on all of my import, Do you have any suggestion for this

Thank you in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests