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.

NOTE: On Linux systems you can only use the NativeScript CLI to develop Android apps. This is because the NativeScript CLI uses Xcode to build iOS apps, which is only available on the macOS operating system.

System Requirements

  • Ubuntu 16.04, 18.04 or 20.04 LTS
  • The latest stable official release of Node.js (LTS) 12.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 environment variables setup for Android development:


Advanced Setup Steps

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

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

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

    We need to enable i386 support on some platforms

    sudo dpkg --add-architecture i386
    sudo apt-get update && sudo apt-get upgrade -y
    • Ubuntu 16.04 & 18.04 LTS base
    sudo apt-get install lib32z1 lib32ncurses5 libbz2-1.0:i386 libstdc++6:i386
    • Ubuntu 20.04 LTS base
    sudo apt-get install lib32z1 lib32ncurses-dev libbz2-1.0:i386 libstdc++6:i386
  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

      nano ~/.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. We need to create a directory to house the android tooling, on most systems the best place is /usr/local/android however if your prefer to use a different directory structure just replace the directorys with your own directory path.

      sudo mkdir -p /usr/local/android/sdk/cmdline-tools && cd /usr/local/android/sdk/cmdline-tools
    2. Go to Android Studio and SDK Downloads and in the Command line tools only section download the package for Linux (at the bottom of the page), you should see the latest version and you can then update the following command to be the latest.

    sudo wget .
    1. After the download completes, unzip the file and remove the download using the following command:

      sudo unzip && sudo rm
    2. Set the ANDROID_HOME & ANDROID_SDK_ROOT environment variables. Open ~/.bashrc

      nano ~/.bashrc

      and add the following:

      export ANDROID_HOME="/usr/local/android/sdk/"
      export ANDROID_SDK_ROOT="/usr/local/android/sdk/"
      export PATH="${PATH}:${ANDROID_SDK_ROOT}cmdline-tools/tools/:${ANDROID_SDK_ROOT}platform-tools/"
      1. Update your current session variables by running:
        source ~/.bashrc
        or 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_SDK_ROOT/cmdline-tools/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.

    Please note this is the recommended, safest and most secure method to install any NPM packages globally.

    sudo npm install nativescript -g --unsafe-perm
  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