I wrote a getting started guide for react-native on macOS and for iOS devices few months ago. Now I thought to write it for android devices as well.
Lets get started...
Official guide suggests to use
Homebrew to install
Watchman. So first thing first, run this command to install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
After brew is installed, run these commands to install
brew install node brew install watchman
Make sure you have 8.3 or newer version of node.
Official guide also recommends to install JDK using
Homebrew. Run this command to get this done.
brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
Make sure you install JDK 8 or newer.
Download and install
Android Studio here.
Now choose to install "Custom" setup for installation and make sure to select checkboxes of these options.
Android SDK Platform
Performance (Intel ® HAXM)
Android Virtual Device
Then, click "Next" to install all of these components.
To install the SDK, open the android studio. Click on the configure button on bottom right corner of "Welcome to Android Studio" screen. Then select "SDK Manager".
Select the "SDK Platforms" tab from the SDK Manager, then check the box next to "Show Package Details" in the bottom right corner. Expand the Android 9 (Pie) entry, then make sure to check these:
Android SDK Platform 28
Intel x86 Atom_64 System Image or Google APIs Intel x86 Atom System Image
Next, select the "SDK Tools" tab and check the box next to "Show Package Details" here as well. Look for and expand the "Android SDK Build-Tools" entry, then make sure that 28.0.3 is selected.
Finally, click "Apply" to download and install the Android SDK and related build tools.
The React Native tools require some environment variables to be set up in order to build apps with native code.
For this we need to write some code in
$HOME/.bashrc config file.
To create a new
.bash_profile file, type
cd ~/ in your terminal.
touch .bash_profile to create your new file, then type
open -e .bash_profile to open your file and add these lines:
export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-tools
$HOME/.bash_profile to load the config into your current shell. Verify that
ANDROID_HOME has been added to your path by running
Now all the dependencies are installed and we can create our new Application. Run this command to create a new React Native App
npx react-native init AwesomeProject
Open your project android folder in Android studio, Click on the AVD (Android Virtual Device) Manager from the menu list.
Select 'Create Virtual Device...' , then pick any Phone from the list and click "Next", then select the Q API Level 29 image.
Click "Next" then "Finish" to create your AVD. After this you will see the green play button next to your AVD. Click it to launch the AVD.
Now finally we are ready to run our react native app in android. Run this command in terminal
npx react-native run-android
I also wrote same blog for iOS devices. Check it here: