This guide outlines the process of setting up React Native development environment on Linux or Ubuntu without relying on Android Studio and EXPO. This setup is particularly useful for developers who prefer minimalistic installations or have specific requirements for their development environment.
Before proceeding with the setup, ensure that the following prerequisites are met:
- Node.js & npm: Install Node.js and npm on your system. You can install them using a package manager like
apt
. - Java Development Kit (JDK): React Native requires JDK to be installed. Ensure JDK is installed on your system.
- Android SDK: Instead of installing Android Studio, we will install the Android SDK separately.
Note: nodejs version should be v.21
You can install Node.js and npm using the following commands:
sudo apt update
curl -sL https://deb.nodesource.com/setup_21.x | sudo -E bash -
sudo apt install -y adb
sudo apt install -y nodejs
Verify the installation using:
node -v
npm -v
Install the Java Development Kit (JDK) using:
sudo apt install openjdk-17-jdk
Verify the installation using:
java -version
Instead 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. eg path: home/user/Android/
- Add the Android SDK tools directory to your system PATH. You can do this by adding the following line to your
.bashrc
file:
nano .bashrc
- Then Add these lines in
.bashrc
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/bin
Replace /path/to/android-sdk
with the actual path where you extracted the Android SDK.
Reload the terminal or run source ~/.bashrc
for the changes to take effect.
Install the React Native CLI globally using npm:
npm install -g react-native-cli
Create a new React Native project using the following command:
npx react-native init MyReactNativeApp
Replace MyReactNativeApp
with your desired project name.
Navigate to your project directory and start the Metro Bundler:
cd MyReactNativeApp
npm start
Open a new terminal window and run your app on an Android emulator or a connected device:
adb devices
npx react-native run-android
Congratulations! You have successfully set up React Native on Linux or Ubuntu without relying on Android Studio.
- Emulator: You can use an emulator such as Genymotion or the Android Emulator provided with the Android SDK to run your React Native apps.
- Device: If you prefer testing on a physical device, enable USB debugging on your Android device and connect it to your computer via USB.
Refer to the React Native documentation for more detailed information on setting up your development environment.
I hope you've found this guide helpful
Follow me on Twitter for more tips.