Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Manually Setup NativeScript Without Use Of Provided Scripts

NativeScript is great. There is an easy setup process (at least for Windows, I unfortunately don’t have a Mac so I can’t speak on the MacOS side of things) that provides an executable that helps you through all the steps of setup. Unfortunately, like any automated setup process, things can go awry and stop your excitement on starting on your native apps with some errors that have little suggestion on how to move forward. This guide will help you go through the steps to install and use NativeScript manually, so whether you’re having difficulties with the simple setup, or want to customize a few things along the way, you’re ready to rock and roll.

Java Development Kit (JDK)

You’ll also need to have JDK 8 installed. The download page can be found here. You’ll want to select Java SE Development Kit 8. This installer should also include the installation option to include Public Java Runtime, which is also known as JRE. This option should be left on as it is needed.

Possible Errors

If you have a previous version of JDK installed, you may need to set a JAVA_HOME path variable equal to the installation path of your JDK install (EG: C:\Program Files\Java\jdk1.8.0_152). More on path variable adding further into this article.

Although this SHOULDN’T be needed, I also had to add my JDK bin folder (EG: C:\Program Files\Java\jdk1.8.0_15\bin) to my path in order to stop all warnings and errors from showing up when installing NativeScript.

Node.js

Node.js is what allows Javascript to run on your desktop outside of the browser. This is needed for NativeScript to be setup and run a development environment for it, but not to run the app once compiled. You can find downloads here.

Android SDK

Download

The next step is a bit more niche. You’re going to want do download the Android SDK. While this is packaged with Android Studio, and a simple install of that would do the job, it also takes up MUCH more space than the SDK alone. If you’re limited on storage, or simply don’t want to have Android Studio take up another slot on your program list, you can setup the command line version of the SDK by itself. Download the ZIP here.

Android SDK CLI Download

Extract the ZIP file to a directory called Android and place it in the respective folder for your platform:

  • Windows: The root of your C: drive
  • MacOS, OSX, and Linux: Your home ~ folder

Add to Path

In order to use the tools in this folder from any location, you’ll need to add the Android/tools and Android/platform-tools folders to your path. This will allow you to run commands from the SDK such as sdkmanager.

Linux and MacOS Path Instructions

Run the command:

nano ~/.bash_profile

And add the line:

export PATH="~/Android/tools:~/Android/platform-tools:$PATH"

Windows Path Instructions

Open Explorer, and right click on This PC and select Properties

Context Menu For This PC

Click on Advanced system settings:

The Menu For Advanced System Settings

It will bring up a dialog for System Properties. In the Advanced tab, click Environment Variables.

Windows System Properties Dialog

Then, click on the Path list item in System variables. Then add C:\Android\platform-tools and C:\Android\tools to the list.

Added Directories To Windows Path

Finally, add a new variable in System variables called ANDROID_HOME with the value C:\\Android

ANDROID_HOME Variable Defined In Windows

Possible Errors

If, after restarting any open cmd or powershell sessions, you are still unable to run sdkmanager, try adding C:\Android\tools\bin to your path as well.

SDK Install

Open a console and run:

sdkmanager 'extras;google;m2repository' 'extras;android;m2repository' 'extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2' 'extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2' 'emulator' 'platform-tools' 'build-tools;25.0.3' 'extras;google;google_play_services' 'extras;intel;Hardware_Accelerated_Execution_Manager' 'platforms;android-24' 'system-images;android-24;google_apis;x86_64'

This will install the needed Android repos, support libraries, build tools, and other SDK tools for Android. You may need to accept licenses. When prompted, type y to accept.

Possible Errors

You may get an error that you’re unable to install Intel Hardware Accelerated Execution Manager. If you encounter this error, check that you have virtualization enabled in your BIOs.

Setup Test Emulator

We need to make a test device to run our app on. In order to do so, run the following command

avdmanager create avd -k 'system-images;android-24;google_apis;x86_64' -d 9 -n "Nexus_5X" -b 'google_apis/x86_64'

This will create a clone of the Nexus 5X to test your app on.

Install NativeScript

Finally, to install NativeScript, run:

npm install -g nativescript

It will prompt you to run the setup script (which is what we’ve essentially already done manually), when it does so, select “No” (type n).

Possible Errors

You may see suggestions (in yellow) and errors (in red) displayed when you run the install command for NativeScript. Be sure to slow down and read these if you come across any errors. Feel free to leave a comment down below if you get stuck.

Bonus: NativeScript Sidekick

Great, you have the framework installed! But now what? I don’t have a template to go off of, have little understanding of the commands I need to run to get it all going; or perhaps, you already know the steps and want to cut off the cruft to get to the goodies. Luckily for you, Progress (the parent company behind NativeScript) has an answer for you: NativeScript Sidekick.

Sidekick allows you to start new projects with a myriad of templates to chose from. You can also go ahead and do things like cloud compiling for iOS projects on a Windows box, and change basic settings for each platform (iOS and Android). What are you waiting for? You can grab your copy here and learn how to use it in a previously written The Polyglot Developer tutorial titled, NativeScript Sidekick For Assisted Project Creation And Cloud Building!

Corbin Crutchley

Corbin Crutchley

Corbin Crutchley is a fan of anything tech related. Always looking for new ways to learn and grow, he spends most days tinkering on a machine of some kind. He has experience with Python, Angular, React, and NativeScript. Corbin cares passionately about documentation and always wants to contribute back.

Search

Follow Us

Support This Site