react-native/docs/DevelopmentSetupAndroid.md

2.9 KiB

id title layout category permalink next
android-setup Android Setup docs Quick Start docs/android-setup.html tutorial

This guide describes basic steps of the Android development environment setup that are required to run React Native android apps on an android emulator. We don't discuss developer tool configuration such as IDEs here.

If you already have the Android SDK

  1. Make sure to update the required packages to the versions mentioned below (see screenshots)

If you don't have the Android SDK

  1. Install the latest JDK
  2. Install the Android SDK:
    • On Mac: brew install android-sdk, add export ANDROID_HOME=/usr/local/opt/android-sdk to your ~/.bashrc, ~/.bash_profile or whatever your shell uses
    • On Linux and Windows: Download from the Android website

Define the ANDROID_HOME environment variable

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:

    # If you installed the SDK via Homebrew, otherwise ~/Library/Android/sdk
    export ANDROID_HOME=/usr/local/opt/android-sdk
    
  • On Linux, add this to your ~/.bashrc, ~/.bash_profile or whatever your shell uses:

    export ANDROID_HOME=<path_where_you_unpacked_android_sdk>
    
  • On Windows, go to Control Panel -> System and Security -> System -> Change settings -> Advanced -> Environment variables -> New

Configure your SDK

  1. Open the Android SDK Manager (on Mac start a new shell and run android); in the window that appears make sure you check:
  • Android SDK Build-tools version 23.0.1
  • Android 6.0 (API 23)
  • Android Support Repository
  1. Click "Install Packages"

SDK Manager window SDK Manager window

Install Genymotion

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.

  1. Download and install Genymotion
  2. Open Genymotion
  3. Create a new emulator and start it

Alternative: Create a stock Google emulator

  1. Start a new shell and run android; in the window that appears make sure you check:
  • Intel x86 Atom System Image (for Android 5.1.1 - API 22)
  • Intel x86 Emulator Accelerator (HAXM installer)
  1. Click "Install Packages".
  2. Configure hardware acceleration (HAXM), otherwise the emulator is going to be slow.
  3. Create an Android Virtual Device (AVD):
  4. Run android avd and click on Create... Create AVD dialog
  5. With the new AVD selected, click Start...