Skip to content

Instantly share code, notes, and snippets.

@peterp peterp/
Last active Jan 22, 2019

What would you like to do?
Installing React-Native on Ubuntu

First, you'll need NodeJS and NPM:

sudo apt install curl
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs
nodejs -v

Then you can install react-native using npm

sudo npm install -g react-native-cli

Now you need to install Java/ Android

sudo apt-get install default-jre
sudo apt-get install default-jdk

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
  • Install Android
  • Install Android SDK requirements
cd ~
mkdir android-sdk
cd android-sdk

We add the path of our Android SDK tools to .bashrc so that we have access to the Android tools.

cd ~
pico .bashrc

# Add these lines to the top of the file
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools

# CTRL+O (uppcase o) to save
# CTRL+X to exit

source ~/.bashrc

Now we have access to the android command

android update sdk --no-ui
# Answer 'y' to all prompts

sdkmanager "platforms;android-23" "build-tools;23.0.1" "add-ons;addon-google_apis-google-23"
  • TODO: Install GenyMotion
  • TODO: Get a project running

Create your first project!

mkdir projects
cd projects
react-native init my-first-project
cd my-first-project

This comment has been minimized.

Copy link

kevinsmithwebdev commented May 17, 2018

Thank you, this helped me. My only comments are:

The instruction:

This of course isn't a linux command (afaik). But downloading it and putting it in that directory worked.

Also, I didn't have a path to sdkmanager and had to find it and explicitly state a path. Maybe I'd missed something else earlier.

But this did get Java off my system, get the correct one installed and things are working now.



This comment has been minimized.

Copy link

CyberArrow commented May 29, 2018

The command I used was: wget Downloading was okay, but I think that was the command you were looking for.


This comment has been minimized.

Copy link

miguelzau commented May 31, 2018

Hi, thanks for the tutorial, but i having this problem when using the android update sdk --no-ui:
Warning: java.lang.RuntimeException: Unexpected error: the trustAnchors parameter must be non-empty
Warning: Failed to download any source lists!
Warning: File /home/miguel/.android/repositories.cfg could not be loaded.

Anyone can help me?

Using Ubuntu 18.04

Solved, i use this link:


This comment has been minimized.

Copy link

iozeen commented Aug 5, 2018

For those wondering how to call: sdkmanager "platforms;android-23" "build-tools;23.0.1" "add-ons;addon-google_apis-google-23"
You should go to android_sdk/tools/bin and call it like this: ./sdkmanager "platforms;android-23" "build-tools;23.0.1" "add-ons;addon-google_apis-google-23"


This comment has been minimized.

Copy link

SakhirAtwi commented Aug 10, 2018

For anyone looking for a step further to create an Andriod Virtual Device, use

avdmanager create avd -n app-emu -k "system-images;android-23;google_apis;x86"

and then run the emulator by:

emulator @app-emu

Side-Note: If you are stuck at sdkmanager --update or android update sdk --no-ui then just be patience, it is going to take 5 minutes min.

Cheers, Happy Coding.



This comment has been minimized.

Copy link

pdenapo commented Nov 10, 2018

I think it is not a good idea to install things like

npm install -g react-native-cli

with the -g parameter, as this requires root permissions (and besides being a security risk, you may be working on a machine where you cannot do sudo) , and the files get installed under the /usr directory where they can mix whit the files installed from Ubuntu packages. Isn't possible to avoid this?


This comment has been minimized.

Copy link

DiogoMaMartins commented Dec 12, 2018

Hi everyone, can someone help me?
I installed following this tutorial,but when i run react-native run-android i have this error

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':app'.

SDK location not found. Define location with sdk.dir in the file or with an ANDROID_HOME environment variable.

I'm not use genymotion i use my device,thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.