Skip to content

Instantly share code, notes, and snippets.

@samuelespinosa
Forked from jamesob/install-steps.sh
Last active May 14, 2025 18:36
Show Gist options
  • Save samuelespinosa/086589ba3972335021de33205ae1b56b to your computer and use it in GitHub Desktop.
Save samuelespinosa/086589ba3972335021de33205ae1b56b to your computer and use it in GitHub Desktop.
Getting to Android and react-native development in Arch Linux (2024)

Android & React Native Development on Linux Using a Docker-Based Emulator

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.


1. Install yay (AUR Helper)

To install packages from the Arch User Repository (AUR), first install yay:

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

2. Install Android Development Packages

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

3. Configure Environment Variables

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

4. Install Android Platform SDK(s)

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'

5. Java Environment Setup

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

6. Run the Android Emulator in a Docker Container

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

7. Connect ADB to the Emulator

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

8. Create and Run a React Native Application

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

9. Access the Emulator UI

You can access the emulator's VNC interface from your browser at:

http://localhost:6080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment