NativeScript - Installation on Linux

For those just starting out on NativeScript here is what you need to get a fully running system on Linux Ubuntu 14.04 (64 bit).

The first step is to do a update and add i386 architecture to your box and then download all the compilers:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y libncurses5:i386 libstdc++6:i386 zlib1g:i386 lib32z1 lib32ncurses5 lib32bz2-1.0 libstdc++6:i386

# Pull in all the Development stuff
sudo apt-get install -y mc linux-headers-generic build-essential g++ ant git openjdk-7-jdk p7zip p7zip-full

Next we need to download and build Node (This takes a while depending on the machine):
sudo wget -q --output-document=/usr/src/node-latest.tar.gz http://nodejs.org/dist/node-latest.tar.gz
pushd /usr/src
sudo tar zxvf node-latest.tar.gz > /dev/null
sudo chown -R $USER:$USER node-v*
cd node-v*
./configure
make
sudo make install
popd

Next we need to download and install the android SDK:
  sudo wget -q --output-document=/usr/src/android-sdk.tgz  http://dl.google.com/android/android-sdk_r24.2-linux.tgz
  pushd /usr/local
  echo Extracting Android SDK...
  sudo tar zxvf /usr/src/android-sdk.tgz > /dev/null
  sudo chown -R $USER:$USER /usr/local/android-sdk-linux
  popd

Next we are going to setup all the Paths so that some of the stuff we run later works properly:
  ANDROID_NDK_FILENAME=android-ndk-r10e
  export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  export ANT_HOME=/usr/local/ant
  export ANDROID_HOME=/usr/local/android-sdk-linux
  export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:/usr/local/$ANDROID_NDK_FILENAME
  echo 'export ANDROID_HOME=/usr/local/android-sdk-linux' >> ~/.bashrc
  echo 'export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:/usr/local/$ANDROID_NDK_FILENAME' >> ~/.bashrc
  echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ~/.bashrc
  echo "export ANT_HOME=/usr/local/ant" >> ~/.bashrc

  if [[ -f ~/.profile ]]; then
    echo 'ANDROID_HOME=/usr/local/android-sdk-linux' >> ~/.profile
    echo 'PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:/usr/local/$ANDROID_NDK_FILENAME' >> ~/.profile
    echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ~/.profile
    echo "export ANT_HOME=/usr/local/ant" >> ~/.profile
  fi

  if [[ -f ~/.bash_profile ]]; then
    echo 'export ANDROID_HOME=/usr/local/android-sdk-linux' >> ~/.bash_profile
    echo 'export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:/usr/local/$ANDROID_NDK_FILENAME' >> ~/.bash_profile
    echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ~/.bash_profile
    echo "export ANT_HOME=/usr/local/ant" >> ~/.bash_profile
  fi

Now we need to install all the Android SDK's, and yes we are install 17, 21, and 22.   17&21 are required for different things.  22 is for the latest sdk.
android update sdk --no-ui --filter platform-tool,android-17,android-21,android-22,build-tools-22.0.1

(OPTIONAL) Now we need install the Android NDK -- This is only needed if you are planning to build actual android runtime and metadata tool.
  ANDROID_NDK_FILENAME=android-ndk-r10e
  sudo wget -q --output-document=/usr/src/$ANDROID_NDK_FILENAME.7z http://dl.google.com/android/ndk/$ANDROID_NDK_FILENAME-linux-x86_64.bin
  sudo chmod a+r /usr/src/$ANDROID_NDK_FILENAME.7z
  sudo mkdir /usr/local/$ANDROID_NDK_FILENAME
  sudo chmod 777 /usr/local/$ANDROID_NDK_FILENAME
  7z x /usr/src/$ANDROID_NDK_FILENAME.7z -o/usr/loca

Now we need to install Grunt, and the nativescript
  sudo npm install grunt -g --unsafe-perm
  sudo npm install grunt-cli -g --unsafe-perm
  sudo npm install nativescript -g --unsafe-perm

And finally we will clone and install each of the primary NativeScript Repo's
  mkdir ~/repos
  pushd ~/repos
  git clone https://github.com/NativeScript/NativeScript
  git clone https://github.com/NativeScript/android-runtime
  git clone https://github.com/NativeScript/nativescript-cli
  git clone https://github.com/NativeScript/android-metadata-generator

  cd NativeScript
  npm install
  cd ..

  cd android-runtime
  npm install
  cd ..

  cd nativescript-cli
  npm install
  cd ..

  cd android-metadata-generator
  npm install
  cd ..

  popd

You now have everything you need to build all the components of NativeScript.   In each of the repos; you can do a grunt to build that specific repo.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.