Nativescript-cli: 'tns devices' does not find emulators

Created on 8 Aug 2017  Β·  19Comments  Β·  Source: NativeScript/nativescript-cli

Did you verify this is a real problem by searching

Couldn't find a solution by searching.

Tell us about the problem

I have followed the installation guide in nativescript.org. I have installed android sdk. Then, installed android studio to create AVD as shown in the guide. AVD is working fine but tns devices command cannot find emulators even though it finds connected android device.

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.1.3
  • Cross-platform modules: Didn't create a project yet
  • Runtime(s): Didn't create a project yet
  • Plugin(s): Didn't create a project yet

Please tell us how to recreate the issue in as much detail as possible.

Create an avd in android studio as shown in the nativescript guide for AVDs. Then run tns devices

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

No code.

question

Most helpful comment

I'm still getting the following error regardless of how I set ANDROID_HOME (with both the Homebrew installation and Android Studio installation).

I've tried both /usr/local/share/android-sdk (for Homebrew) and /Users/$user/Library/Android/sdk (for Android Studio)

Also I have an emulator installed but NativeScript still does not find it when I run tns run android --bundle

The error I get is the following:

Cannot find connected devices.
Emulator start failed with: No emulator image available for device identifier 'undefined'.
To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
To list available emulator images, run 'tns device <Platform> --available-devices'.

When I run tns device android --available-devices, a device shows up but it still says the following:

tns device android --available-devices

Available emulators
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Device Name   β”‚ Platform β”‚ Version   β”‚ Device Identifier β”‚ Image Identifier β”‚ Error Help β”‚
β”‚ Pixel 3 API Q β”‚ Android  β”‚           β”‚                   β”‚ Pixel_3_API_Q    β”‚            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Connected devices & emulators
Searching for devices...
Cannot find connected devices. Reconnect any connected devices, verify that your system recognizes them, and run this command again.

All 19 comments

In this guide they create an AVD and run tns devices and it works. That didn't work for me.
However, after creating a project and running tns run android it worked. Maybe we need to run that command first before ever running tns devices. Strange behaviour.

Hi @erkanarslan,

tns device or tns devices gives you a list of all connected/started devices in the moment of executing the command. If you need to check available emulator images you can execute tns devices android --available-devices or tns devices ios --available-devices.

That problem is fixed after runing 'tns run android' on a project. Now,
'tns devices' lists available emulators without any flag.

On Aug 10, 2017 08:47, "pkoleva" notifications@github.com wrote:

Hi @erkanarslan https://github.com/erkanarslan,

tns device or tns devices gives you a list of all connected/started
devices in the moment of executing the command. If you need to check
available emulator images you can execute tns devices android
--available-devices or tns devices ios --available-devices.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/NativeScript/nativescript-cli/issues/3044#issuecomment-321456929,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALZXewct0X-4B5ZsTcsgNRnggZiUFEDnks5sWplsgaJpZM4Ow7iO
.

Hi @erkanarslan,

What I mean by available devices is all images you have created on your machine and started or connected devices are the ones that are currently running. So when no emulators are running and no devices are paired tns device will output empty list, since there are no currently running devices. And once you have at least one running emulator/device it will return a list with it.

Hope this clears out a bit how the command was intended to work.

Thanks, this clears the problem.

Just installed all components based on Teleriks recommendations on my Mac. All fine so far. I've created the Helloworld App and tried to start it:
_Got the following error message: tns run android
Cannot find connected devices.
Emulator start failed with: Cannot run your app in the native emulator. Increase the timeout of the operation with the --timeout option or try to restart your adb server with 'adb kill-server' command. Alternatively, run the Android Virtual Device manager and increase the allocated RAM for the virtual device.
To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
To list available emulator images, run 'tns device --available-devices'._

There are two devices in the list that I have added to ADV (Android_ARMv7a , Android_Accelerate d_x86)

"tns run ios" is working tough

Same for me. What I did to workaround this (that I don't know if this would cause problems in the future) is to install android studio manually and then in my bash_profile i changed the path of ANDROID_HOME to the path of the android studio's sdk -> /Users/username/Library/Android/sdk

Then run
source ~/.bash_profile
and try running
tns run android

@Taygair did you use the install script or did you go with the advanced setup?

Nah, I did it the same way as you did, was the most obvious way to do it.

I just uninstalled the sdk that brew had installed using
brew cask uninstall android-sdk
and now I can run both the emulator from android studio and the command line using tns

The android-sdk makes it easy to add further emulators (different mobile)

I had a similar issue (tns run android was not working). The NativeScript Advanced Installation instructions say to set ANDROID_HOME to /usr/local/share/android-sdk. But when I changed it to /Users//Library/Android/sdk it started working. It was a fresh install of NativeScript on a macbook pro High Sierra 10.13.4.

@kormic
@thomasjlee

Uninstalling the brew-installed sdk and changing my ANDROID_HOME path to "/Users/..." did the trick. Thanks!

I'm still getting the following error regardless of how I set ANDROID_HOME (with both the Homebrew installation and Android Studio installation).

I've tried both /usr/local/share/android-sdk (for Homebrew) and /Users/$user/Library/Android/sdk (for Android Studio)

Also I have an emulator installed but NativeScript still does not find it when I run tns run android --bundle

The error I get is the following:

Cannot find connected devices.
Emulator start failed with: No emulator image available for device identifier 'undefined'.
To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
To list available emulator images, run 'tns device <Platform> --available-devices'.

When I run tns device android --available-devices, a device shows up but it still says the following:

tns device android --available-devices

Available emulators
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Device Name   β”‚ Platform β”‚ Version   β”‚ Device Identifier β”‚ Image Identifier β”‚ Error Help β”‚
β”‚ Pixel 3 API Q β”‚ Android  β”‚           β”‚                   β”‚ Pixel_3_API_Q    β”‚            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Connected devices & emulators
Searching for devices...
Cannot find connected devices. Reconnect any connected devices, verify that your system recognizes them, and run this command again.

@voigtd Hello, I have encountered the same problem, how can I solve it in the end?

I have the same problem too. I’ve been trying to solve for 3 days but it’s not working.

Any solution?

@louis-morgan It's been awhile since I've dealt with this but I remember writing my solution in the following issue: #4596

The problem is that the Android version is too high, try instead of 11 use 10 or lower

I'm still getting the following error regardless of how I set ANDROID_HOME (with both the Homebrew installation and Android Studio installation).

I've tried both /usr/local/share/android-sdk (for Homebrew) and /Users/$user/Library/Android/sdk (for Android Studio)

Also I have an emulator installed but NativeScript still does not find it when I run tns run android --bundle

The error I get is the following:

Cannot find connected devices.
Emulator start failed with: No emulator image available for device identifier 'undefined'.
To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
To list available emulator images, run 'tns device <Platform> --available-devices'.

When I run tns device android --available-devices, a device shows up but it still says the following:

tns device android --available-devices

Available emulators
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Device Name   β”‚ Platform β”‚ Version   β”‚ Device Identifier β”‚ Image Identifier β”‚ Error Help β”‚
β”‚ Pixel 3 API Q β”‚ Android  β”‚           β”‚                   β”‚ Pixel_3_API_Q    β”‚            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Connected devices & emulators
Searching for devices...
Cannot find connected devices. Reconnect any connected devices, verify that your system recognizes them, and run this command again.

I have encountered the exact same issue. I got it resolved by running the following commands:

adb kill-server
adb start-server

and make sure the emulator has been booted successfully with the following command:

emulator -avd <emulator_name>
Was this page helpful?
0 / 5 - 0 ratings