This guide provides step-by-step instructions for setting up Android and React Native development on a Linux system by leveraging a containerized Android emulator. This setup ensures a clean, reproducible environment and simplifies system configuration.
To install packages from the Arch User Repository (AUR), first install yay
:
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Install the core Android development tools, following the Arch Wiki guidelines:
yay -Sy android-sdk-cmdline-tools-latest \
android-sdk-build-tools \
android-sdk-platform-tools \
android-platform
Add the following block to your ~/.zshrc
or ~/.bashrc
to make Android tools available in your shell:
if [ -d /opt/android-sdk ]; then
export ANDROID_HOME="/opt/android-sdk"
export PATH="$PATH:$ANDROID_HOME/tools/bin"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin"
export PATH="$PATH:$ANDROID_HOME/emulator"
fi
After saving the changes, restart your terminal session:
exec $SHELL
List available platforms:
/opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --list | grep platforms
Install the latest platform (e.g., android-36):
/opt/android-sdk/cmdline-tools/latest/bin/sdkmanager 'platforms;android-36'
You can also install additional versions if needed:
/opt/android-sdk/cmdline-tools/latest/bin/sdkmanager 'platforms;android-34' 'platforms;android-35'
React Native and Android SDK tools have different Java version requirements:
- JDK 8 is needed to accept licenses.
- JDK 17 is required to run React Native CLI and tools.
# Install JDK 8 and set as default
sudo pacman -Sy jre8-openjdk
sudo archlinux-java set java-8-openjdk/jre
# Accept licenses
sdkmanager --licenses
# Switch to JDK 17
sudo pacman -Sy jdk17-openjdk
Start the emulator using Docker. The --network host
flag is required to allow the emulator to access the local development server.
docker run -d --network host \
-e EMULATOR_DEVICE="Samsung Galaxy S10" \
-e WEB_VNC=true \
--device /dev/kvm \
--name android-container \
budtmo/docker-android:emulator_11.0
Use the following commands to connect the Android Debug Bridge (ADB) to the emulator:
adb connect $(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' android-container):5555
adb devices -l # Verify that the emulator is connected
Create a new React Native project:
npx react-native@latest init YOUR_PROJECT
cd YOUR_PROJECT
Start the Metro bundler:
npm start
In a separate terminal, launch the app on the Android emulator:
npm run android
You can access the emulator's VNC interface from your browser at:
http://localhost:6080