Search code examples
androidmacosnativescriptandroid-sdk-toolsangular2-nativescript

NativeScript can't find Android SDK on Mac OS


I've installed NativeScript and I try to do tns platform add android but it doesn't work. ANDROID_HOME path is correct and I have installed SDK (API 22 and the newest one) and tools (25.0.2). When I run tns doctor it says:

WARNING: The Android SDK is not installed or is not configured properly.
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.

You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=25.0.2'.

You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.

Solution

  • The current version of NativeScript 2.5.2 requires certain tools to be in the Android home directory so that it can detect them. The newest version of Android SDK (Mar 2017) actually removed the primary android support file and moved several binary files into other directories to clean things up.

    Unfortunately this causes NativeScript to not be able to detect that you have the SDK. This version of the SDK came out AFTER the current version of NativeScript.

    The simplest way to fix this that I can think of is to start from the command line; sdkmanager then choose to download the older 25.2.3 tools.

    To manually do this; you would need to delete everything in your sdk/tools folder and download:

    https://dl.google.com/android/repository/tools_r25.2.3-windows.zip (Windows) https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip (Macintosh) https://dl.google.com/android/repository/tools_r25.2.3-linux.zip (Linux)

    Then extract these into that sdk/tools directory.