Skip to content

Instantly share code, notes, and snippets.

@jdnichollsc
Last active November 20, 2024 16:32
Show Gist options
  • Select an option

  • Save jdnichollsc/08a0d6a1b27962c4c4dd78ffbbfe768c to your computer and use it in GitHub Desktop.

Select an option

Save jdnichollsc/08a0d6a1b27962c4c4dd78ffbbfe768c to your computer and use it in GitHub Desktop.
Run React Native apps in x86_64 devices using Termux and TermuxArch and running in a Linux chroot

Ok, if you're a newbie like me this is the process (After enable the termux storage permissions):

Initialize TermuxArch

startarch

Create a backup of your pacman configuration

tar zcf mirrorlist.tar.gz /etc/pacman.d/
cp /etc/pacman.conf storage/downloads/pacman.conf
cp /etc/pacman.d/mirrorlist storage/downloads/mirrorlist
// Now you can edit the configuration :)
nano /etc/pacman.conf
nano /etc/pacman.d/mirrorlist

Install pacman packages manually

pacman -S git
pacman -S binutils
pacman -S pkgfile
pacman -S unzip
pacman -S fakeroot
pacman -S nodejs
pacman -S npm
npm install -g yarn // Yarn is a other good option to have
pacman -Syy; pacman -Su; pacman -S jdk8-openjdk

Create a new user to use makepkg command

useradd -m myuser
su myuser
makepkg

Install the tools required to build your app

  • Install android-sdk:
cd ~/
git clone https://github.com/termux/termux-packages.git
./termux-packages/scripts/setup-android-sdk.sh
  • Set Environment Variables
nano $HOME/.bash_profile
# Append these lines at the end of the file:
export ANDROID_HOME=$HOME/lib/android-sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
#end
source $HOME/.bash_profile
echo $ANDROID_HOME
/root/lib/android-sdk  // Yay!

Eureka! You can build react-native apps now from your device! 💯

npm install -g react-native-cli
react-native init AwesomeProject
cd AwesomeProject
react-native run-android

Detect your architecture

uname -m

Update the package list and upgrade

pacman -Syu

@bloodykheeng
Copy link

are you using expo

@Shpantze
Copy link

Shpantze commented Nov 20, 2024

are you using expo

Yeah, but I'm talking about building locally with expo run:android which would basically be the equivalent of gradle assembleDebug or assembleRelease not necessarily relying on EAS for remote builds.

*Oh and furthermore for anyone who's interested, I don't really know how it will work because it's never got completely through the build steps yet, but I used a little trick when getting selenium to work a while back where you run an adb daemon in termux and it allows your local device to attach as an emulator on 5554...idk🤷🏼‍♂️ I adb reversed tcp:5554 and it allows a connection and expo to start building.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment