This guide will walk you through installing React Native and setting up your physical Android device for development on an Arch-based Linux distribution.
If you haven't installed yay yet, do so with the following commands:
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -siInstead of installing Android Studio, we'll install the Android SDK separately. Follow these steps:
- Download the custom Android Command Line Tools
- Extract the downloaded archive to a suitable location on your system. e.g.,
home/user/Android/ - Add the Android SDK tools directory to your system PATH. You can do this by adding the following lines to your
.bashrcfile:
nano ~/.bashrcThen add these lines at the end of the file:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/binSave and exit, then apply the changes:
source ~/.bashrcTo install JDK, run the following command:
yay -S jdk-openjdksudo pacman -S android-tools android-udev
sudo gpasswd -a $USER adbusers
newgrp adbusers
sudo udevadm control --reload-rules
sudo udevadm triggeryay -S nvm
echo 'source /usr/share/nvm/init-nvm.sh' >> ~/.bashrc
source ~/.bashrcnvm install --lts
nvm alias default lts/*
npm install -g yarn
yarn global add react-native-clinpx react-native@latest init MyApp
OR
npx @react-native-community/cli init MyAppsdkmanager "build-tools;35.0.0"To check if your setup is correct, run:
npx react-native doctorIf everything is correctly configured, proceed with building and running your app:
npx react-native run-androidAfter the build process completes, stop it using Ctrl + C, then start the Metro bundler separately:
npx react-native startNow, you should be able to use your physical device for React Native development!
I hope you've found this guide helpful