NativeScript Angular

NativeScript Advanced Setup: Linux

This page contains a list of all system requirements needed to build and run NativeScript apps on Linux, as well as a guided walkthrough for getting these requirements in place.

System Requirements

  • Ubuntu 14.04 LTS
  • The latest stable official release of Node.js (LTS) 10.x
  • G++ compiler
  • JDK 8
  • Android SDK
  • Android Support Repository
  • (Optional) Google Repository
  • Android SDK Build-tools 28.0.3 or a later stable official release

You must also have the following two environment variables setup for Android development:

  • JAVA_HOME
  • ANDROID_HOME

Advanced Setup Steps

Complete the following steps to set up NativeScript on your Linux development machine:

  1. Install the latest Node.js 10.x stable official release.

  2. If you are running on a 64-bit system, install the runtime libraries for the ia32/i386 architecture.

    sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 libstdc++6:i386
    

    If you encounter an error showing "Unable to locate package lib32bz2-1.0" then use

    sudo apt-get install lib32z1 lib32ncurses5 libbz2-1.0:i386 libstdc++6:i386
    

    Package lib32ncurses5 is only available as version 6 on Ubuntu >v.19.04, replace with lib32ncurses6.

  3. Install the G++ compiler.

    sudo apt-get install g++
    
  4. Set up [JDK 8] JDK 8.

    1. Run the following commands.

      
      sudo apt-get install openjdk-8-jdk
      
    2. After installation if you have multiple installations of java you can choose which to use:

      sudo update-alternatives --config java
      
    3. Set the JAVA_HOME system environment variable. Open ~/.bashrc and add the following:

      export JAVA_HOME=$(update-alternatives --query javac | sed -n -e 's/Best: *\(.*\)\/bin\/javac/\1/p')

      You may need to reload the bashrcfile either by logging out and in again, or by running source .bashrc in the terminal from your Home directory.

  5. Install the Android SDK.

    1. Go to Android Studio and SDK Downloads and in the SDK Tools Only section download the package for Linux at the bottom of the page.
    2. After the download completes, unpack the downloaded archive into a folder, such as /usr/local/android/sdk
      • The archive you just extracted was the tools folder, so in this case it would be at: /usr/local/android/sdk/tools
    3. Set the ANDROID_HOME environment variable. Open ~/.bashrc and add the following:
      export ANDROID_HOME="/usr/local/android/sdk/"
      export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
    4. In a text file which was opened, paste in the path to your variable (at the new line).

    For example: ANDROID_HOME=/usr/local/android/sdk

    NOTE: This is the directory that contains the tools (just installed) and platform-tools (installed by scripts in the next step) directories.
    1. Logout from current user and login again so environment variables changes take place.
  6. Install all packages for the Android SDK Platform 28, Android SDK Build-Tools 28.0.3 or later, Android Support Repository, Google Repository and any other SDKs that you may need. You can alternatively use the following command, which will install all required packages. In order to install SDK's go to Android Studio -> Settings -> System Settings -> Android SDK -> Mark all the Android versions you would like to support within your project (The API Level column indicates the SDK Platform).

    sudo $ANDROID_HOME/tools/bin/sdkmanager "tools" "emulator" "platform-tools" "platforms;android-28" "build-tools;28.0.3" "extras;android;m2repository" "extras;google;m2repository"
    
  7. Setup Android Emulators (AVD) by following the article here

    1. After creating an emulated device you need to:
      • Enable its Developer mode - go to Settings -> About emulated device and tap 7 times on Build number
      • Enable USB debugging - go to Settings -> Developer options and enable USB Debugging
  8. Install the NativeScript CLI.

    1. Run the following command.
    sudo npm install nativescript -g --unsafe-perm
    
    1. Restart the command prompt.
  9. To check if your system is configured properly, run the following command.

    tns doctor
    

If you see "No issues were detected" you are good to go!

NativeScript tns doctor result

What’s Next