Motivation: build local, test performance of release build on a real device.
Environment: Expo SDK 46 managed project, on AlmaLinux 8.6 (ymmv)
Caution:
I keep a copy of my entire project dir in case things get messed up:
cd <project *parent* dir>
\cp -far <project dir name> <project dir name>.bak
and update that when appropriate with
cd <project dir> # if not there
rsync -atvi --delete . ../<project dir name>.bak/
Steps to create android project dirs/files and a debug build apk :
cd <project dir>
npx expo run:android # not the same as "npm run android"
see ref in official expo docs here
release build:
cd <projectDir>/android/app
keytool -genkey -v -keystore <projectName>.keystore -alias <<projectName>> -keyalg RSA -keysize 2048 -validity 10000
ammend android/app/build.gradle
file - see details here but do not use the build instructions (atow). Then ...
cd ../../ # to project dir
npx expo run:android --no-install --no-bundler --variant release
(although tbh I'm guessing for now that --no-bundler
is to do with the Metro server)
You should find a release apk in
<project dir>/android/app/build/outputs/apk/release
Note this includes full expo and the build can take quite a while. It took more than 12 mins on the following:
Operating System: AlmaLinux 8.6
KDE Plasma Version: 5.23.3
KDE Frameworks Version: 5.88.0
Qt Version: 5.15.2
Kernel Version: 4.18.0-372.32.1.el8_6.x86_64 (64-bit)
Graphics Platform: X11
Processors: 12 × Intel® Xeon® CPU E5-2620 v3 @ 2.40GHz
Memory: 31.1 GiB of RAM
Graphics Processor: AMD CEDAR
You can reduce build time and the final apk size by going for an expo development build or moving your code to a porn project (plain old react-native) :-)
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.