Android Setup # | Edit on GitHub |
This guide describes basic steps of the Android development environment setup that are required to run React Native android apps on an android emulator.
On Mac, if you have installed XCode, Git is already installed, otherwise run the following:
On Linux, install Git via your package manager.
On Windows, 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.
brew install android-sdk
IMPORTANT: Make sure the ANDROID_HOME
environment variable points to your existing Android SDK:
On Mac, add this to your ~/.bashrc
, ~/.bash_profile
or whatever your shell uses:
On Linux, add this to your ~/.bashrc
, ~/.bash_profile
or whatever your shell uses:
On Windows, go to Control Panel
-> System and Security
-> System
-> Change settings
-> Advanced
-> Environment variables
-> New
NOTE: You need to restart the Command Prompt (Windows) / Terminal Emulator (Mac OS X, Linux) to apply the new Environment variables.
React Native Android use gradle as a build system. We recommend to enable gradle daemon functionality which may result in up to 50% improvement in incremental build times for changes in java code. Learn here how to enable it for your platform.
android
); in the window that appears make sure you check:
Genymotion is much easier to set up than stock Google emulators. However, it's only free for personal use. If you want to use the stock Google emulator, see below.
android
; in the window that appears make sure you check:android avd
and click on Create...
Start...
The Visual Studio Emulator for Android is a free android emulator that is hardware accelerated via Hyper-V. 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:
regedit.exe
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools
Android SDK Tools
and choose New > String Value
Path
Path
Key and set the value to C:\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.
You can use any editor to edit JavaScript. If you want to use Android Studio to work on native code, from the Welcome screen of Android Studio choose "Import project" and select the android
folder of your app.