DEV Community

ROHIT SINGH
ROHIT SINGH

Posted on

Setup React Native App Development Environment on Ubuntu /Linux Without Android Studio 2024

*Setup React Native App Development Environment on Ubuntu/Linux
*

In the world of mobile app development, React Native has emerged as a powerful framework for building cross-platform applications with ease. Its ability to write code once and deploy it across multiple platforms like iOS and Android makes it a favorite among developers. However, setting up a React Native development environment can sometimes be a daunting task, especially when it comes to integrating with Android Studio on Linux systems.

Fortunately, there's a way to bypass the reliance on Android Studio and streamline the setup process, specifically tailored for Ubuntu users. In this article, we'll guide you through the step-by-step process of setting up** React Native on Ubuntu without the need for Android Studio.**

Prerequisites

Before we dive into the installation process, make sure you have the following prerequisites:

  1. Ubuntu operating system installed on your machine.
  2. Basic knowledge of using the terminal.
  3. Stable internet connection.

Step 1: Install Node.js and npm

Node.js and npm are essential for running JavaScript-based applications. To install them, open your terminal and run the following commands:

sudo apt update
curl -sL https://deb.nodesource.com/setup_21.x | sudo -E bash -
sudo apt install -y nodejs
Enter fullscreen mode Exit fullscreen mode

After installation, verify that Node.js and npm are successfully installed by running:

node -v
npm -v
Enter fullscreen mode Exit fullscreen mode

Step 2: Install JDK (Java Development Kit)

React Native requires JDK for building and running Android applications. Install JDK by executing the following command:

sudo apt install openjdk-17-jdk
Enter fullscreen mode Exit fullscreen mode

Verify the JDK installation by running:

java -version
Enter fullscreen mode Exit fullscreen mode

Step 3: Download and Install Android Command Line Tools

Instead of installing Android Studio, we'll download the Android Command Line Tools and set them up manually. Follow these steps:

  1. Download the custom Android Command Line Tools from this link.
  2. Extract the downloaded archive to a suitable location on your system. For example, you can extract it to $HOME/Android.

Update System PATH

To ensure that the Android SDK tools are accessible from anywhere in the terminal, update the system PATH. Open the .bashrc file using a text editor:

nano ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Add the following lines to 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/bin
Enter fullscreen mode Exit fullscreen mode

Save the file and reload the terminal or run source ~/.bashrc for the changes to take effect.

Step 4: Install React Native CLI

React Native CLI is a command-line interface that allows you to create, build, and run React Native applications. Install it globally using npm:

npm install -g react-native-cli
Enter fullscreen mode Exit fullscreen mode

Step 5: Create a New React Native Project

With React Native CLI installed, you can create a new React Native project by running:

npx react-native init MyReactNativeApp
Enter fullscreen mode Exit fullscreen mode

Replace MyReactNativeApp with your desired project name.

Step 6: Run Your React Native App

Navigate to your project directory and start the Metro Bundler:

cd MyReactNativeApp
npm start
Enter fullscreen mode Exit fullscreen mode

Open a new terminal window and run your app on an Android emulator or a connected device:

adb devices
npx react-native run-android
Enter fullscreen mode Exit fullscreen mode

Congratulations! You have successfully set up React Native on Ubuntu without relying on Android Studio. You're now ready to dive into React Native development and build amazing cross-platform applications.

Additional Notes

  • Make sure to regularly update Node.js, npm, and other dependencies to the latest versions for optimal performance and security.
  • Troubleshooting: If you encounter any issues during the setup process, refer to the official documentation or seek help from the vibrant React Native community.

With this streamlined setup, Ubuntu users can harness the power of React Native to build high-quality mobile applications without the overhead of Android Studio.

I hope you've found this guide helpful

Follow me on twitter. for more tips. Happy coding!

Top comments (1)

Collapse
 
josersleal profile image
JL

where does the emulator come from?