Cannot find a compatible Android SDK for compilation when running `tns platform add android`
Asked 07 September, 2021
Viewed 2.1K times
  • 57
Votes

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!

8 Answer