expo / eas-cli

Fastest way to build, submit, and update iOS and Android apps
https://docs.expo.dev/eas/
MIT License
814 stars 83 forks source link

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

Closed martin-braun closed 2 years ago

martin-braun commented 2 years ago

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
dsokal commented 2 years ago

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?

martin-braun commented 2 years ago

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 commented 2 years ago

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

martin-braun commented 2 years ago

@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?

dsokal commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

I would like to know that too. Thanks!

Youngermaster commented 1 year ago

@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 commented 1 year ago

@Youngermaster Many thanks. Will try later.

Youngermaster commented 1 year ago

@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 commented 1 year ago

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 commented 11 months ago

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 commented 10 months ago

@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 commented 9 months ago

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 commented 6 months ago

@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 commented 4 months ago

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 commented 3 months ago

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 commented 1 month ago

@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