Recently I came to know about the NativeScript platform for developing cross-platform mobile applications. Although there are a whole lot of similar platforms and tools already available out there, what enticed me the most towards NativeScript was the fact that it mentioned that the apps were Truly Native.
So, I thought to give this a try and started with setting up of NativeScript on my Windows 7 machine. Obviously, the first step was to setup the environment for NativeScript to run. Asa a result, I followed their Setup and Installation guide. I already had Node installed so directly went and ran the npm command to install NativeScript:
npm install -g nativescript
During the install, I was asked once if I wanted to install any required tools automatically or not. So, just to make my life simple, I just went ahead and selected the “All” option. But that is possibly what I did wrong and realised later.
Once the installation was complete, I could run tns or nativescript on command line and confirm that installation was complete.
Next step was to try with the sample project they have to offer. As a result, I went ahead and cloned the sample-groceries application directory using the command:
git clone https://github.com/NativeScript/sample-Groceries.git
When the cloning was complete, next step to do was to “Add Target Development Platforms”. As I was on a Windows machine, I ran the command for Android.
tns platform add android
The command took some time to execute and I was soon presented with an error saying:
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
But, I knew I already had that installed with the Android Studio which was present on my system prior to the installation of NativeScript.
After struggling for a while, I remembered that NativeScript also did some Android installation of itself when I pressed “a” during the installation time. This made me think that probably the SDK version being used by it is the issue.
I went ahead to check the Environment Variables and Check the ANDROID_HOME and PATH variables. What I found was that it was referring to the folder with the name “android-sdk”.
On checking the folder, I found that there was another folder located on the same location with the name “sdk”. On checking both, I found that the “sdk” folder was much big in size and probably the one which was setup by Android Studio. While the one with the name “android-sdk” must be the one which was setup by NativeScript.
I went ahead and changed the values of Android_Home and Path variables. And guess what, it fixed the issue! I was able to set Android as one of the target platforms.