Skip to content

Latest commit

 

History

History
183 lines (124 loc) · 7.07 KB

File metadata and controls

183 lines (124 loc) · 7.07 KB
title Setting up Windows for NativeScript
prev /setup
next /guide/creating-a-project
contributors
rigor789
herefishyfish

Setting up Windows for Android

You will need Node, a JDK (java development kit), Android Studio and the NativeScript CLI (command line interface).

Android Studio is not strictly necessary — however it provides an easy-to-use interface for installing and managing the Android SDKs.

We recommend using Chocolatey to install the required dependencies — a popular package manager for Windows.

Setting up the Android development environment can be daunting if you are new to Android development, however following the next steps carefully will get you up and running in no time.

Installing Node

To install Node we recommend using a node version manager, such as nvm-windows, nvs or any other node version manager you prefer. In these docs we will be using nvm-windows, but feel free to use a different node version manager.

  1. Install nvm-windows using one of the following methods: ::: code-group

    choco install -y nvm
    https://github.com/coreybutler/nvm-windows#installation--upgrades
    

    :::

  2. After installation, open a new Command Prompt and verify:

    nvm version
  3. Once the installation is complete, open a new Command Prompt and verify you can run nvm ls.

  4. Install the latest Node release with:

    nvm install node
  5. Verify the installation was successful and run

    node -v
    npm -v

::: warning Troubleshooting

If any of the above failed, we recommend checking out the Microsoft Docs for Setting up Node, or asking in our Community Discord for assistance.

:::

Installing a JDK

To install a JDK (using the prebuilt OpenJDK binaries from Adoptium) open an Administrator Command Prompt (right click and select "Run as Administrator") and run the following command:

choco install -y temurin21

Once installed, you might need to add it to your Path. First, check if you need to add it to your Path by opening a new Command Prompt and running the following:

javac --version

If you see a version number printed, you may skip this step. Otherwise, you will need to add the JDK binaries to your system environment Path:

  1. Search for "Edit the system environment variables" in Windows Search and select
  2. Click on "Environment variables..." in the bottom corner
  3. Under the "User variables for..." select the Path variable and click Edit...
  4. Click New and add the JDK bin folder path to the list. The JDK location may vary depending on the version you have installed.
    C:\Program Files\Eclipse Adoptium\jdk-21.0.9.10\bin
    

Additionally, some installations may require creating the JAVA_HOME environment variable manually:

  1. Search for "Edit the system environment variables" in Windows Search and select
  2. Click on "Environment variables..." in the bottom corner
  3. Click on New... under the "User variables for..." section
  4. Add the following variable. Ensure you're using the correct JDK path, without the \bin suffix. Example:
    VARIABLE_NAME: JAVA_HOME
    VARIABLE_VALUE: C:\Program Files\Eclipse Adoptium\jdk-21.0.9.10-hotspot
    

You may need to restart your terminal for changes to apply.

Installing Android Studio

Download and install Android Studio. In the installation wizard make sure you have the following components selected (the list should appear if you select custom options):

The setup may take a while, but once it has finished a welcome screen should appear.

Android Studio installs the latest Android SDK by default, which in most cases should be all that's needed to build a NativeScript app.

Configuring ANDROID_HOME and PATH

Configure the ANDROID_HOME environment variable for NativeScript to be able to find the Android SDK.

  1. Search for "Edit the system environment variables" in Windows Search and select
  2. Click on "Environment variables..." in the bottom corner
  3. Under the "User variables for..." click on New... to create the ANDROID_HOME user variable that points to the path of the Android SDK:

New User Variable (ANDROID_HOME)

The SDK is by default located at:

%LOCALAPPDATA%\Android\Sdk

To find the actual location in the Android Studio Settings, navigate to Languages & Frameworks › Android SDK and copy the Android SDK Location.

Next, add Android platform-tools to path:

  1. Search for "Edit the system environment variables" in Windows Search and select
  2. Click on "Environment variables..." in the bottom corner
  3. Under the "User variables for..." select the Path variable and click Edit...
  4. Click New and add the platform-tools path to the list. The default location is inside the Android SDK's platform-tools folder:
    %LOCALAPPDATA%\Android\Sdk\platform-tools
    

Installing the NativeScript CLI

Install the NativeScript CLI globally:

npm install -g nativescript

Verifying the environment

To verify that the installation was successful, open a new Command Prompt window (to ensure the new environment variables are loaded) and run:

ns doctor android

If you see No issues were detected then you have successfully set up your system.

If you're using Chocolatey and prefer not to open a new terminal, you can refresh your environment variables in the current PowerShell session by running:

Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1"
Update-SessionEnvironment

After refreshing, run the ns doctor command again to confirm everything is working as expected.

Lastly, you will also want to set up an android device or emulator.

::: warning Troubleshooting

If any of the above failed, we recommend asking in our Community Discord for assistance.

:::

Setting up Windows for iOS

:::danger ❌ Unsupported

A Mac is required to build projects that use native iOS code. Simpler apps can be tested using NativeScript Preview.

:::