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

@fahadali32
Copy link

Make a video at youtube pls sir that how to install react-native at termux

@bloodykheeng
Copy link

is there a video on YouTube

@jdnichollsc
Copy link
Author

Do you still need that?

@K-cod
Copy link

K-cod commented Apr 12, 2023

Yes pls do make a video, i don't understand the start

@mevadakalpesh
Copy link

Yes please need video

@rkmsnc
Copy link

rkmsnc commented Feb 3, 2024

please let us know the emulator settings

@Shpantze
Copy link

Shpantze commented Nov 20, 2024

Has anyone successfully managed to build react-native apps with Termux? I've tried with Arch and Debian proot and the standard terminal instance to no avail... I've gotten close but it essentially fails at probably anything to do with cmake, but specifically the react native reanimated library.
I think the ndk needs to be built specifically for the architecture but I'm using a prebuilt one and honestly C and C++ are kind of out of my scope of experience so I can't figure out how to successfully configure the CMakeLists.txt for that library to do the right thing on Android or how to configure (or which to configure) the build.gradle to properly recognize C and C++ environment variables to use the correct toolchains in the suggested ndk by Izhiyong.
Anyone have more knowledge or experience of actually getting this to work?

Oh I guess I should state I was trying to simply get a base minimal default Expo project to build.

@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