Nativescript-cli: Add support for Android SDK Tools 25.2.3

Created on 2 Mar 2017  路  28Comments  路  Source: NativeScript/nativescript-cli

A few days ago i updated my android sdk (with android-studio) and also switched from nativescript 2.4.x to 2.5.2, but during the setup (and also after executing tns doctor) it seems like nativescript is not able to find an appropriate targetSdk

Selected version is:  25.0.2
Selected targetSdk is: undefined
Selected AppCompat version is: undefined

It looks like the cli uses the android command of the sdk tools, but this command is not available anymore

spawn: .../Sdk/tools/android "list" "targets"
Result when throw error is false:
{ stdout: 'The android command is no longer available.\nFor manual SDK and AVD management, please use Android Studio.\nFor command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager\n',
  stderr: '',
  exitCode: 1 }
The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager

So i am not able to setup android for nativescript.

I am using the android sdk tools version 25.3.1 and NativeScript 2.5.2.

question

Most helpful comment

I experienced the same issue.

What's funny is that I ran android from the command line to update my SDK tools (to 25.3.1). After I updated, I tried to run android again, but it failed.

This SO answer suggests that the previous version of Android SDK Tools be installed.

https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip (for mac).
https://dl.google.com/android/repository/tools_r25.2.3-windows.zip (for windows).

Just replace the old tools/ directory in the folder pointed to by your $ANDROID_HOME.

All 28 comments

I experienced the same issue.

What's funny is that I ran android from the command line to update my SDK tools (to 25.3.1). After I updated, I tried to run android again, but it failed.

This SO answer suggests that the previous version of Android SDK Tools be installed.

https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip (for mac).
https://dl.google.com/android/repository/tools_r25.2.3-windows.zip (for windows).

Just replace the old tools/ directory in the folder pointed to by your $ANDROID_HOME.

@EricRobertBrewer @eisverticker this doesn't look like a NativeScript problem, but a problem with Android Tooling.

@Plamen5kov I don't think so, because if there is an API change in the Android toolings and this causes NativeScript to fail, then it is also a problem for NativeScript or their users as long as it is not documented that newer versions of the sdk don't work with NativeScript.

same here , i was reminded by Android Studio of updating new components and itself , then i updated, after that "tns doctor " gives warning like this "Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later."

Android SDK Tools : 25.3.1
Android SDK Platform-Tools:25.0.3

After updating Android Studio my gradle failed to sync with this message 'android command is no longer available'

I followed the steps in this thread to try and roll back the Android tooling (downloading the 23.2.3 version) and replacing - however, I still get the same message.

I'm in the same boat as @edwardmhunton

https://developer.android.com/studio/releases/sdk-tools.html

It is a change in the SDK tools, and if you've downloaded the latest - then NativeScript may not work for you. I advice downloading the older SDK tools (releases prior to March 2017) as a temporary workaround.

Hi everyone. I ended up here after googling the error message I get when I try running android in my terminal. I don't really know much about NativeScript, so maybe this is not useful for you guys, but I'll share anyway...

What previously needed android avg is now its own tool called avdmanager. On my installation of the sdk, android is located at Library/Android/sdk/tools/android, and avdmanager is located at Library/Android/sdk/tools/bin/avdmanager. I hope this is useful for somebody?

Maybe it's just inattention when you'll create the path. In my case, this was just innattetion. One / more caused all the problem. Even in creating of the path, even the calling commands together with my variable path.

I hope this tips help you.

has this problem been fixed yet or any time soon ? or should we roll back to older version of Android SDK Tools ? Thanks !

Hey @c1ngular , we are working on the fix and it will be available in @next version of CLI very soon. We are preparing 2.5.3 release of NativeScript CLI, where this issue will be fixed.

@rosen-vladimirov thanks !

Same problem here
@rosen-vladimirov thank you very much for all the effort you guys put in this project

@rosen-vladimirov .... Can you give an estimate on when this is solved? Thanks!!!

@Dutchboy the fix is already in master branch, you can try it by installing @next version of CLI:

npm i -g nativescript@next

We plan to release 2.5.3 in the beginning of the next week :)

@rosen-vladimirov Thanks!!! And.... How quick your answer!!! Two minutes?!!? THANKS

@next version worked. Thanks!

Hey
Having this issue again.

Seems this just goes on forever. Same issue on 10/22/17, NS version 3.2.1

@locohost Please be more specific, as we won't be able to help you otherwise. Thank you!

Ok. I'm on Win 8 developer laptop Dell Precision M2800 with 16GB of RAM and nearly half of the 500GB HD empty. I use this laptop for node dev nearly every day.

I'm using the latest NS version 3.2.1. I've fully updated my Android SDK. SDK manager shows no more updates to install. I've run the NS setup process. I've pasted the powershell script line from documentation and run that. What more do I have to do? I'm assuming there are more undocumented steps to get this working. See attached screen cap. Thanks for helping.

nativescript cannot be used cmdr window

@locohost I noticed several messages that could hint at something you could have missed during the setup.

ANDROID_HOME errors - make sure you have installed the extras packages using the sdkmanager android sdk tools executable ("extras;android;m2repository" "extras;google;m2repository"); Also verify that ANDROID_HOME/tools and ANDROID_HOME/platform-tools are set in your PATH environment variable. Finally you may need to restart the system/relog for the changes to the environment to take effect.

javac error - our android builds do not yet support Java 9, we are working on enabling the use of JDK 1.9. In the meantime please consider setting your JAVA_HOME to point to the Oracle JDK 8 distribution.

I'm having similar issues as @locohost

I just tried running the NS install script on my Mac:

ruby -e "$(curl -fsSL https://www.nativescript.org/setup/mac)"

This seems to have failed to install Android. Running sdkmanager gives me error:

$ sdkmanager: command not found

I have Homebrew installed which I believe is used as part of the NS install script to attempt to install android-sdk, internally using the following command (or similar):

$ brew cask install android-sdk

However, this fails as I believe the brew is no longer maintained.

So I installed the latest Android Studio and used the embedded SDK Manager; the ANDROID_HOME environment variable by Studio is now set to:

ANDROID_HOME=/Users/<user>/Library/Android/sdk

Also, I have Java 9 installed; I see from the above comment that only Java 8 is supported.

So a few questions:

  • Can I use NS with the latest Android Studio managing the ANDROID_HOME environment variable and no sdkmanager command line?
  • Tips on running Java 8 in parallel to Java 9?

@sjordan1975:

Can I use NS with the latest Android Studio managing the ANDROID_HOME environment variable and no sdkmanager command line?

It should be no problem using the setup provided with the Android Studio bundle, as long as the $ANDROID_STUDIO environment variable is set correctly.

Tips on running Java 8 in parallel to Java 9?

  • If you start Android Studio from the command line like: ./android-studio/bin/studio.sh it will use whatever environment variables are set in the current terminal. So If you set the export JAVA_HOME ... to java 8 and then start Android studio, it should use java 8.
  • Another way would be using jenv. I haven't tested this way.

@Plamen5kov Hi,Thank you for your reply; can you provide a little more instruction.

Thank you for the suggestion of _jenv_; I have managed to get both Java 8 and Java 9 on my machine.

Inside my NS project, I ran the following command:

tns run android

and got error:

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

I have latest Android Studio (Android SDK 27)

@sjordan1975 currently Oracle Java 9 is not supported for NativeScript Android development. Refer to the following comment https://github.com/NativeScript/nativescript-cli/issues/2265#issuecomment-340232515.

As for your Android SDK setup - make sure your ANDROID_HOME, ANDROID_HOME/tools and ANDROID_HOME/platform_tools are present in your PATH environment.

UPDATE Finally able to get things running by following instructions here

The gist of it seems that as of November 4, the current version of NativeScript does not work with the last SDK; same problem and fix alluded to here

@Pip3r4o Thank you. I've fixed the Java 9 issue.

Here are the relevant variables:

export ANDROID_HOME=/Users/sjordan/Library/Android/sdk
export PATH=$PATH:/Users/sjordan/Library/Android/sdk/tools
export PATH=$PATH:/Users/sjordan/Library/Android/sdk/platform-tools

Running:

tns doctor

Output:

Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
Run $ $ANDROID_HOME/tools/bin/sdkmanager to manage your Android SDK versions.

You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=26'.
Run $ $ANDROID_HOME/tools/bin/sdkmanager from your command-line to install required Android Build Tools.

You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
Run $ $ANDROID_HOME/tools/bin/sdkmanager to manage the Android Support Repository.
Was this page helpful?
0 / 5 - 0 ratings