Cannot find a compatible Android SDK for compilation when running `tns platform add android`

lazlojuly picture lazlojuly · Sep 22, 2015 · Viewed 19.1k times · Source

I am following an official NativeScript tutorial and having a problem configuring my OS X environment for android development.

When running tns platform add android I receive the following error:

Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 21 or later.

The tns doctor command also returns warnings on android-sdk issues:

Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 21 or later. Run $ android to manage your Android SDK versions. You need to have the Android SDK Build-tools installed on your system. You have to install version 22. Run "android" from your command-line to install required Android Build Tools. You need to have the latest Android Support Repository installed on your system. Run $ android to manage the Android Support Repository.

My android-sdk installation looks like this:

Android-SDK-installations

My .bash_profile also includes the followings:

export ANDROID_HOME="/usr/local/Cellar/android-sdk/24.3.4/"

export PATH="$PATH:~/npm-global/bin:/usr/local/Cellar/android-sdk/24.3.4/tools:/usr/local/Cellar/android-sdk/24.3.4/platform-tools"

Should I go further and try setting system-wide environment variables - not just for the .bash_profile? Also, it is possible that I missed something from the setup process...

Any tip on how I could debug this situation (commands, config files etc.) would be great, thank you!

Answer

Aniruddh picture Aniruddh · Sep 23, 2015

Alright, so you need to make sure of following:

  • Make sure you have API 22 installed.
  • Make sure you you have Android SDK Build Tools 22.x.x installed. (Yes, specifically 22.x.x)
  • Make sure you have Android support repository installed. (You can find it under Extras section in Android SDK Manager)

Once you have performed steps mentioned above, run tns doctor again and you should see No issues were detected message.