Reputation: 841
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:
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!
Upvotes: 27
Views: 24484
Reputation: 13
This is an updated answer, I also had the same issue:
Like all the previous pictures above, I had to install the SDK platforms, using the SDK Manager. From the main screen of Android Studio, click More Actions and choose SDK Manager. Before that I had to add the platform-tools to my PATH in Windows
%LOCALAPPDATA%\Android\Sdk\platform-tools
That fixed my issue and the docs for setup are here.
Upvotes: 0
Reputation: 649
I always got the error "✖ Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 28 or later. "
I actually had to go to the android studio settings and install the exact SDK 28 before this error went away. Android Settings Pic
Upvotes: 0
Reputation: 328
This answer is on a Linux, not OSX, platform. However, since this is the SO that appears most often for the listed error, I'll share a recent fix that worked for me.
If you have done all of the above and are still getting the error, try this solution.
I am using NativeScript 8.0.2.
You will know that ANDROID_HOME and Java are configured correctly if you can run the command $ANDROID_HOME/tools/bin/sdkmanager --list
. If that fails, then first check that your Java is compatible (I had to add OpenJDK 8 and change my PATH with export JAVA_HOME="/usr/lib64/jvm/java-1.8.0/"
)
In Android Studio, add a previous build tool version. Go to your SDK Manager > SDK Tools, tick the bottom box "Show package details", and add a previous version. In my case, 31.0.0 was the latest, and I added 30.0.3. Now run ns doctor android
again and everything should pass.
Seems 31.0.0 is not yet properly recognised by Native Script.
Upvotes: 0
Reputation: 193
on my windows 10 machine I had to open file explorer right click on this pc and go to properties on the left hand side I had to go to advanced settings. At the bottom I click environment variables then on the android_home variable I clicked edit then pointed it to this path on my machine where the sdk was installed C:\Program Files (x86)\Android\android-sdk
Upvotes: 0
Reputation: 23
Run the following
Run
tns run android
then it should be OK
Upvotes: 2
Reputation: 5535
I solve this problem installing Android Support Repository
from Extras
.
Upvotes: 1
Reputation: 1652
For Windows User:
ps:- adding this answer, so that if any one land on this page can see it.
Upvotes: 7
Reputation: 7668
Alright, so you need to make sure of following:
Once you have performed steps mentioned above, run tns doctor
again and you should see No issues were detected
message.
Upvotes: 24