48 KiB
id, title, original_id
| id | title | original_id |
|---|---|---|
| version-0.28-getting-started | getting-started | getting-started |
Getting Started # | Edit on GitHub |
Target: iOS Android Development OS: Mac Linux Windows
Unsupported #

Installation #
Required Prerequisites #
Homebrew #
Homebrew, in order to install the required NodeJS, in addition to some recommended installs.
Node #
Use Homebrew to install Node.js.
NodeJS 4.0 or greater is required for React Native. The default Homebrew package for Node is currently 6.0, so that is not an issue.
React Native Command Line Tools #
The React Native command line tools allow you to easily create and initialize projects, etc.
If you see the error,
EACCES: permission denied, please run the command:sudo npm install -g react-native-cli.
Xcode #
Xcode 7.0 or higher is required. You can install Xcode via the App Store or Apple developer downloads. This will install the Xcode IDE and Xcode Command Line Tools.
While generally installed by default, you can verify that the Xcode Command Line Tools are installed by launching Xcode and selecting
Xcode | Preferences | Locationsand ensuring there is a version of the command line tools shown in theCommand Line Toolslist box. The Command Line Tools give yougit, etc.
Android Studio #
Android Studio 2.0 or higher.
Android Studio requires the Java Development Kit [JDK] 1.8 or higher. You can type
javac -versionto see what version you have, if any. If you do not meet the JDK requirement, you can download it.
Android Studio will provide you the Android SDK and emulator required to run and test your React Native apps.
Unless otherwise mentioned, keep all the setup defaults intact. For example, the
Android Support Repositoryis installed automatically with Android Studio, and we need that for React Native.
You will need to customize your installation:
- Choose a
Custominstallation
- Choose both
PerformanceandAndroid Virtual Device
- After installation, choose
Configure | SDK Managerfrom the Android Studio welcome window.
- In the
SDK Platformswindow, chooseShow Package Detailsand underAndroid 6.0 (Marshmallow), make sure thatGoogle APIs,Intel x86 Atom System Image,Intel x86 Atom_64 System Image, andGoogle APIs Intel x86 Atom_64 System Imageare checked.
- In the
SDK Toolswindow, chooseShow Package Detailsand underAndroid SDK Build Tools, make sure thatAndroid SDK Build-Tools 23.0.1is selected.
ANDROID_HOME Environment Variable #
Ensure the ANDROID_HOME environment variable points to your existing Android SDK. To do that, add
this to your , /.bashrc/.bash_profile (or whatever your shell uses) and re-open your terminal:
/usr/local/opt/android-sdk
export ANDROID_HOME=~/Library/Android/sdk
Highly Recommended Installs #
Watchman #
Watchman is a tool by Facebook for watching changes in the filesystem. It is recommended you install it for better performance.
Flow #
Flow, for static typechecking of your React Native code (when using Flow as part of your codebase).
Add Android Tools Directory to your PATH #
You can add the Android tools directory on your PATH in case you need to run any of the Android
tools from the command line such as android avd. In your or /.bash/.bash_profile:
Gradle Daemon #
Enable Gradle Daemon which greatly improves incremental build times for changes in java code.
Other Optional Installs #
Git #
Git version control. If you have installed Xcode, Git is already installed, otherwise run the following:
Nuclide #
Nuclide is an IDE from Facebook providing a first-class development environment for writing, running and debugging React Native applications.
Get started with Nuclide here.
Genymotion #
Genymotion is an alternative to the stock Google emulator that comes with Android Studio. However, it's only free for personal use. If you want to use Genymotion, see below.
- Download and install Genymotion.
- Open Genymotion. It might ask you to install VirtualBox unless you already have it.
- Create a new emulator and start it.
- To bring up the developer menu press ⌘+M
Troubleshooting #
Virtual Device Not Created When Installing Android Studio #
There is a known bug on some versions of Android Studio where a virtual device will not be created, even though you selected it in the installation sequence. You may see this at the end of the installation:
If you see this, run android avd and create the virtual device manually.
Then select the new device in the AVD Manager window and click Start....
Shell Command Unresponsive Exception #
If you encounter:
try downgrading your Gradle version to 1.2.3 in <project-name>/android/build.gradle (https://github.com/facebook/react-native/issues/2720)
Installation #
Required Prerequisites #
Chocolatey #
Chocolatey is a package manager for Windows similar to yum and
apt-get. See the website for updated instructions, but installing from
the Terminal should be something like:
Normally when you run Chocolatey to install a package, you should run your Terminal as Administrator.
Python 2 #
Fire up the Termimal and use Chocolatey to install Python 2.
Python 3 will currently not work when initializing a React Native project.
Node #
Fire up the Terminal and type the following commands to install NodeJS from the NodeSource repository:
Fire up the Termimal and use Chocolatey to install NodeJS.
React Native Command Line Tools #
The React Native command line tools allow you to easily create and initialize projects, etc.
If you see the error,
EACCES: permission denied, please run the command:sudo npm install -g react-native-cli.
Android Studio #
Android Studio 2.0 or higher.
Android Studio requires the Java Development Kit [JDK] 1.8 or higher. You can type
javac -versionto see what version you have, if any. If you do not meet the JDK requirement, you can download it, or use a pacakage manager to install it (e.g.choco install jdk8,apt-get install default-jdk).
Android Studio will provide you the Android SDK and emulator required to run and test your React Native apps.
Unless otherwise mentioned, keep all the setup defaults intact. For example, the
Android Support Repositoryis installed automatically with Android Studio, and we need that for React Native.
You will need to customize your installation:
- Choose a
Custominstallation
- Choose
Android Virtual Device
Make sure all components are checked for the install, particularly the
Android SDKandAndroid Device Emulator.After the initial install, choose a
Custominstallation.
- Verify installed components, particularly the emulator and the HAXM accelerator. They should be checked.
- After installation, choose
Configure | SDK Managerfrom the Android Studio welcome window.
- In the
SDK Platformswindow, chooseShow Package Detailsand underAndroid 6.0 (Marshmallow), make sure thatGoogle APIs,Intel x86 Atom System Image,Intel x86 Atom_64 System Image, andGoogle APIs Intel x86 Atom_64 System Imageare checked.
- In the
SDK Toolswindow, chooseShow Package Detailsand underAndroid SDK Build Tools, make sure thatAndroid SDK Build-Tools 23.0.1is selected.
ANDROID_HOME Environment Variable #
Ensure the ANDROID_HOME environment variable points to your existing Android SDK.
To do that, add this to your , /.bashrc/.bash_profile (or whatever your shell uses) and
re-open your terminal:
/usr/local/opt/android-sdk; Generally with Android Studio, the SDK is installed here...
export ANDROID_HOME=~/Android/Sdk
You need to restart the Terminal to apply the new environment variables (or
sourcethe relevant bash file).
Go to Control Panel -> System and Security -> System -> Change settings ->
Advanced System Settings -> Environment variables -> New
Your path to the SDK will vary to the one shown below.
You need to restart the Command Prompt (Windows) to apply the new environment variables.
Highly Recommended Installs #
Watchman #
Watchman is a tool by Facebook for watching changes in the filesystem. It is recommended you install it for better performance.
This also helps avoid a node file-watching bug.
Type the following into your terminal to compile watchman from source and install it:
Flow #
Flow, for static typechecking of your React Native code (when using Flow as part of your codebase).
Type the following in the terminal:
Gradle Daemon #
Enable Gradle Daemon which greatly improves incremental build times for changes in java code.
Android Emulator Accelerator #
You may have seen the following screen when installing Android Studio.
If your system supports KVM, you should install the Intel Android Emulator Accelerator.
Add Android Tools Directory to your PATH #
You can add the Android tools directory on your PATH in case you need to run any of the Android
tools from the command line such as android avd.
In your or /.bashrc/.bash_profile:
Go to Control Panel -> System and Security -> System -> Change settings ->
Advanced System Settings -> Environment variables -> highlight PATH -> Edit...
The location of your Android tools directories will vary.
Other Optional Installs #
Git #
Install Git via your package manager
(e.g., sudo apt-get install git-all).
You can use Chocolatey to install git via:
Alternatively, you can download and install Git for Windows.
During the setup process, choose "Run Git from Windows Command Prompt", which will add git to your
PATH environment variable.
Nuclide #
[Nuclide] is an IDE from Facebook providing a first-class development environment for writing, running and debugging React Native applications.
Get started with Nuclide here.
Genymotion #
Genymotion is an alternative to the stock Google emulator that comes with Android Studio. However, it's only free for personal use. If you want to use the stock Google emulator, see below.
- Download and install Genymotion.
- Open Genymotion. It might ask you to install VirtualBox unless you already have it.
- Create a new emulator and start it.
- To bring up the developer menu press ⌘+M
Visual Studio Emulator for Android #
The Visual Studio Emulator for Android is a free android emulator that is hardware accelerated via Hyper-V. It is an alternative to the stock Google emulator that comes with Android Studio. It doesn't require you to install Visual Studio at all.
To use it with react-native you just have to add a key and value to your registry:
- Open the Run Command (Windows+R)
- Enter
regedit.exe - In the Registry Editor navigate to
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools - Right Click on
Android SDK Toolsand chooseNew > String Value - Set the name to
Path - Double Click the new
PathKey and set the value toC:\Program Files\Android\sdk. The path value might be different on your machine.
You will also need to run the command adb reverse tcp:8081 tcp:8081 with this emulator.
Then restart the emulator and when it runs you can just do react-native run-android as usual.
Troubleshooting #
Unable to run mksdcard SDK Tool #
When installing Android Studio, if you get the error:
then install the standard C++ library:
Virtual Device Not Created When Installing Android Studio #
There is a known bug on some versions of Android Studio where a virtual device will not be created, even though you selected it in the installation sequence. You may see this at the end of the installation:
If you see this, run android avd and create the virtual device manually.
Then select the new device in the AVD Manager window and click Start....
Shell Command Unresponsive Exception #
In case you encounter
try downgrading your Gradle version to 1.2.3 in <project-name>/android/build.gradle (https://github.com/facebook/react-native/issues/2720)
Testing Installation #
You can also open the
AwesomeProjectfolder in Nuclide and run the application, or openios/AwesomeProject.xcodeprojand hit theRunbutton in Xcode.
You can also open the
AwesomeProjectfolder in Nuclide and run the application.
Modifying Project #
Now that you successfully started the project, let's modify it:
- Open
index.ios.jsin your text editor of choice (e.g. Nuclide) and edit some lines. - Hit ⌘-R in your iOS simulator to reload the app and see your change!
- Open
index.android.jsin your text editor of choice (e.g. Nuclide) and edit some lines. - Press the
Rkey twice OR open the menu (F2 by default, or ⌘-M in Genymotion) and select Reload JS to see your change! - Run
adb logcat *:S ReactNative:V ReactNativeJS:Vin a terminal to see your app's logs
That's It #
Congratulations! You've successfully run and modified your first React Native app.

Testing Installation #
Troubleshooting Run #
A common issue is that the packager is not started automatically when you run
react-native run-android. You can start it manually using:
Or if you hit a ERROR Watcher took too long to load on Windows, try increasing the timeout in this file (under your node_modules/react-native/).
Modifying Project #
Now that you successfully started the project, let's modify it:
- Open
index.android.jsin your text editor of choice (e.g. Nuclide) and edit some lines. - Press the
Rkey twice OR open the menu (F2 by default, or ctrl-M in the emulator) and select Reload JS to see your change! - Run
adb logcat *:S ReactNative:V ReactNativeJS:Vin a terminal to see your app's logs
That's It #
Congratulations! You've successfully run and modified your first React Native app.

Common Followups #
- If you want to run on a physical device, see the Running on iOS Device page.
- If you want to run on a physical device, see the Running on Android Device page.
- If you run into any issues getting started, see the Troubleshooting page.
Common Followups #
If you want to run on a physical device, see the Running on Android Device page.
If you run into any issues getting started, see the Troubleshooting page.
// If we are coming to the page with a hash in it (i.e. from a search, for example), try to get // us as close as possible to the correct platform and dev os using the hashtag and block walk up. var foundHash = false; if (window.location.hash !== '' && window.location.hash !== 'content') { // content is default var hashLinks = document.querySelectorAll('a.hash-link'); for (var i = 0; i < hashLinks.length && !foundHash; ++i) { if (hashLinks[i].hash === window.location.hash) { var parent = hashLinks[i].parentElement; while (parent) { if (parent.tagName === 'BLOCK') { var devOS = null; var targetPlatform = null; // Could be more than one target os and dev platform, but just choose some sort of order // of priority here.
// Dev OS
if (parent.className.indexOf('mac') > -1) {
devOS = 'mac';
} else if (parent.className.indexOf('linux') > -1) {
devOS = 'linux';
} else if (parent.className.indexOf('windows') > -1) {
devOS = 'windows';
} else {
break; // assume we don't have anything.
}
// Target Platform
if (parent.className.indexOf('ios') > -1) {
targetPlatform = 'ios';
} else if (parent.className.indexOf('android') > -1) {
targetPlatform = 'android';
} else {
break; // assume we don't have anything.
}
// We would have broken out if both targetPlatform and devOS hadn't been filled.
display('os', devOS);
display('platform', targetPlatform);
foundHash = true;
break;
}
parent = parent.parentElement;
}
}
} } // Do the default if there is no matching hash if (!foundHash) { var isMac = navigator.platform === 'MacIntel'; var isWindows = navigator.platform === 'Win32'; display('os', isMac ? 'mac' : (isWindows ? 'windows' : 'linux')); display('platform', isMac ? 'ios' : 'android'); } </script>
We are planning improvements to the React Native documentation. Your responses to this short survey will go a long way in helping us provide valuable content. Thank you!





















