How to build Expo APK local
Solution 1
New to the party, so guessing this wasn't available at the time of the post - Instructions for building expo apps locally: Building Standalone Apps on Your CI
Solution 2
if you want to generate apk eject the CRNA with npm run eject command. Then you will get android and ios folders suppurate in mac and you will get an only android folder in windows. and follow the instruction which is in a given link below
"https://facebook.github.io/react-native/docs/signed-apk-android.html"
Solution 3
I've straggled with similar issue, I managed to solve it following several steps found on the web, and tweaking a bit: https://forums.expo.io/t/expokit-full-local-build-without-publish-android/31400/2
Run the https server your machine, note that the server must have a certificate since it is a HTTPS server (I used port 4443), but it does not need to be trusted by your machine - it works anyway
(I found it easy to use: https://gist.github.com/dergachev/7028596 - Python 2.7, https://gist.github.com/dergachev/7028596#gistcomment-1989299 - Python 3.X)Go to your Expo project folder, make sure there is no
dist
folder in it; alternatively you can provide dist path with the--output-dir
flag (the react-native bundle and assets will be generated to it).Open command line and run:
expo export -t bare --dev --public-url https://localhost:4443/
, once done you will have the android bundle and assets in theoutput-dir
(default -dist
)Copy the android bundle from
dist/bundles/android-<bunch of numbers (MD5)>.js
to<YourExpoProjectFolder>/android/app/src/main/assets/index.android.bundle
and to<YourExpoProjectFolder>/android/app/build/generated/assets/react/release/index.android.bundle
(note: the name of the bundle must be index.android.bundle)
In /dist/bundles/assets you'll have your assets files, but they would be named as their MD5 value, copy each of them to<YourExpoProjectFolder>/android/app/src/main/assets/
, but add theasset_
prefix and.<ext>
for each.
e.g. for a PNG image file with MD5 value of de57a0c7a3a23aabcaceaf1185b1e79e:copy <YourExpoProjectFolder>/dist/bundles/assets/de57a0c7a3a23aabcaceaf1185b1e79e <YourExpoProjectFolder>/android/app/src/main/assets/asset_de57a0c7a3a23aabcaceaf1185b1e79e.png
cd android
gradlew.bat assemble
expo diagnostics output:
Expo CLI 3.18.6 environment info:
System:
OS: Windows 10 10.0.18363
Binaries:
Node: 12.16.2
Yarn: 1.22.0
npm: 6.14.4
npmPackages:
expo: ~37.0.3 => 37.0.8
react: ~16.9.0 => 16.9.0
react-native: ~0.61.5 => 0.61.5
react-navigation: ^4.3.9 => 4.3.9
Piu130
Updated on January 14, 2021Comments
-
Piu130 over 3 years
Is it possible to build the APK of an expo app locally?
The doc says:
If you haven’t used exp before, the first thing you’ll need to do is login with your Expo account using
exp login
.I tried
exp start
,exp build:android
but the commands require a login.I don't want to build the APK using expo server. Is there a way to run this build locally? So no login and push of source code required?
If not, can I view the whole source code of the generated APK?
-
Piu130 over 6 yearsIf you use no
expo
imports in your project you can create a project withreact-native-cli
and copy your code. But if you useexpo
I don't have a solution yet. -
Sujit over 6 yearsok, will let you know once I have found anything. Thanks mate.
-
-
user514949 about 4 yearsUpdate: In case you have additional assets, build may fail (on
expo bundle-assets
step) due to: <br/> forums.expo.io/t/… Note - Icon and the android bundle asset does not cause failure.