Skip to content

Instantly share code, notes, and snippets.

@breitembach
Forked from glocore/Instructions.md
Created May 30, 2018 00:32
Show Gist options
  • Save breitembach/1d24df27ef760bdd47d13f63bf1d87f9 to your computer and use it in GitHub Desktop.
Save breitembach/1d24df27ef760bdd47d13f63bf1d87f9 to your computer and use it in GitHub Desktop.
Setup React Native on Ubuntu 16.04/16.10

1. Install Node.js

  • Follow the steps given here to install Node.js and NPM.
  • Verify whether NPM is installed by typing npm -v in a terminal window.

2. Install React Native CLI

  • npm install -g react-native-cli

3. Setup Android Development Environment

  • Download and install Android Studio as explained here.

  • Run Android Studio and open the SDK Manager. Under the SDK Platforms tab, check Show Package Details, expand Android 6.0 (Marshmallow) and check the following:

    • Google APIs
    • Android SDK Platform 23
    • Intel x86 Atom_64 System Image
    • Google APIs Intel x86 Atom_64 System Image
  • Under the SDK Tools tab, check Show Package Details, expand Android SDK Build Tools and check 23.0.1.

  • Click Apply to install all the selected packages.

  • Open a terminal window and type sudo gedit ~/.profile

  • Add the following lines to the end of the file:

    export ANDROID_HOME=${HOME}/Android/Sdk
    export PATH=${PATH}:${ANDROID_HOME}/tools
    export PATH=${PATH}:${ANDROID_HOME}/platform-tools
    
  • Type source ~/.profile in your terminal to load the config into your current shell.

  • In Android Studio, open AVD Manager and click Create Virtual Device

  • Follow the setup wizard and give your device an appropriate name (you will need this name everytime you start the emulator through the command line, so make it short and simple). Click on Finish to create the Virtual Device.

  • If you set the Emulated Performance setting to Software, you will be able to run the emulator, but the performance will be very sluggish. Hence it is recommended to configure VM hardware acceleration.

4. Configure VM acceleration

  • Install cpu-checker: sudo apt-get install cpu-checker
  • Check for KVM compatibility: kvm-ok If the output is says:
    INFO: /dev/kvm exists
    KVM acceleration can be used
    
    it means that your computer can be configured for VM acceleration.
  • Follow the steps given in this Ubuntu documentation in order to configure KVM.
  • Install lib64stdc++6 and mesa-demos: apt-get install lib64stdc++6:i386 mesa-utils
  • Rename libstdc++.so.6 to libstdc++.so.6.bak:
     cd ~/Android/Sdk/emulator/lib64/libstdc++`
    `mv libstdc++.so.6 libstdc++.so.6.bak
    
  • Start the emulator:
    cd ~/Android/Sdk/tools
    ./emulator @foo
    
    replace foo with the name of your device. This should start your Android Emulator in VM accelerated mode.

5. Create and run a React Native application

  • Create a new React Native project: react-native init HelloWorld
  • Navigate to your project directory and type: npm start
  • In another terminal window, navigate to the project directory and type: react-native run-android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment