Skip to content

Setting up React Native

Philippe Cohen edited this page Sep 8, 2016 · 20 revisions

To install react native you need to make sure you have:

Initial setup

nodeJS

     curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
     sudo apt-get install -y nodejs
     sudo apt-get install -y build-essential

This will also install the npm, the Node.js package manager.

JAVA

Download Java JDK, we choose Java SE Development Kit 8u102 java 64x. Open the new folder (java) location and extract to /opt this way

    sudo tar -xvf ~/Downloads/jdk-8u102-linux-x64.tar.gz
    sudo unzip ~/Downloads/jdk1.8.0_102 -d /opt

Android SDK and Android Studio

Download the [Android SDK] (https://developer.android.com/studio/index.html) and extract it to the new folder:

    sudo unzip ~/Downloads/android-studio-ide-143.2915827-linux.zip -d /opt

Add to the PATH Java and Android by editing the ~/.zshrc

    PATH="/opt/java/jdk1.8.0_102/bin:/opt/google/android-studio/bin:~/Android/Sdk/tools/:~/Android/Sdk/platform-tools/:$PATH"

and from the shell:

    source .zshrc    
    rehash

And check your path typing:

    which java
    which studio.sh
    which android 

.... ###SET the ANDRIOD_HOME

To save the place of Android folder you need set the Path in ANDROID_HOME

So in ~./zshrc

export ANDROID_HOME="$HOME/Android/Sdk"

save the change.

Launch Android SDK

  • You will need to have the C++ runtime library so

         sudo apt-get install lib32stdc++6
         exec studio.sh
    
  • To use AVD (Android virtual Device) to simulate a device, you need the KVM virtualization tool that requires the Processor to be configured for virtualization. From the BOIS (FnF2 on the Lenovo Ideapads), go to configuration and change intel virtual technology to enable

New you can launch your emulator by running the emulator command

Creating the first React-native project

   npm install -g react-nativ-cli
   react-native init <Your project name>
   cd <Your project name>

You will encounter several errors with missing SDK components such as

  • Google API 23.1: Add it directly from the Android Studio and select Tool|systemSetting|AndroidSDK and check the Show Package Details checkbox. Then add Google API for API 23 (Marshmallow) and Apply

(IMAGE!) -- ADD PICTURE ---

  • You may encounter additional errors about Build Tools missing and then do

          android list sdk -a
    

look in the list and find this lines:

  • 6- Android SDK Build-tools, revision 23.0.3
  • 7- Android SDK Build-tools, revision 23.0.2
  • 8- Android SDK Build-tools, revision 23.0.1
  • 9- Android SDK Build-tools, revision 23 (Obsolete)

check what their numbers to type:

 - android update sdk -a -u -t 8
  • Then you may encounter a bug with libz.so, to solve this

      sudo apt-get install lib32z1
    
  • Now you should be ok to run your React Native application!!!

       cd <Your project name>
    
       emulator -avd <your emulator name>
       react-native run-android
    

Make it easy to use react native in shell

Add react-native to the plugins in zshrc

  plugins=(git react-native adb heroku ruby rails rake postgres rvm node npm sublime brew  history  osx)

Resources: