Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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!

like image 545
lazlojuly Avatar asked Sep 22 '15 17:09

lazlojuly


People also ask

What SDK do I need to build on Android?

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

Why can’t I see the Android SDK on my developer machine?

@rashnk it is likely an incorrect path to the ANDROID_HOME directory. Please double check that you can find %ANDROID_HOME%/platforms, %ANDROID_HOME%/tools, %ANDROID_HOME%/extras on your developer machine. It is possible that you have not installed the extras package of the Android SDK that has the android support repositories included.

How do I Manage my Android SDK versions?

Run $ android to manage your Android SDK versions. You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system. Run $ android to manage the Android Support Repository.

What do I need to install Android support repository?

You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system. Run $ android to manage the Android Support Repository. Please HELP!


2 Answers

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.

like image 153
Aniruddh Avatar answered Sep 16 '22 14:09

Aniruddh


This is because of sudo. The root user has no ANDROID_HOME set.

like image 45
llj Avatar answered Sep 19 '22 14:09

llj