nativescript-cli icon indicating copy to clipboard operation
nativescript-cli copied to clipboard

'tns devices' does not find emulators

Open erkanarslan opened this issue 9 years ago • 19 comments

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.

erkanarslan avatar Aug 08 '17 15:08 erkanarslan

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.

erkanarslan avatar Aug 08 '17 16:08 erkanarslan

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.

pkoleva avatar Aug 10 '17 05:08 pkoleva

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" [email protected] 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 .

erkanarslan avatar Aug 10 '17 05:08 erkanarslan

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.

pkoleva avatar Aug 17 '17 06:08 pkoleva

Thanks, this clears the problem.

erkanarslan avatar Aug 17 '17 08:08 erkanarslan

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

Taygair avatar Jan 24 '18 02:01 Taygair

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?

kormic avatar Feb 13 '18 22:02 kormic

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

Taygair avatar Feb 13 '18 22:02 Taygair

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

kormic avatar Feb 13 '18 22:02 kormic

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

Taygair avatar Feb 13 '18 22:02 Taygair

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.

thomasjlee avatar May 23 '18 21:05 thomasjlee

@kormic @thomasjlee

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

jayoma avatar Apr 26 '19 07:04 jayoma

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 avatar May 07 '19 22:05 voigtd

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

long-hai-yang avatar Sep 10 '19 11:09 long-hai-yang

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

Saface89 avatar Oct 09 '19 07:10 Saface89

Any solution?

louis-morgan avatar May 15 '20 13:05 louis-morgan

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

voigtd avatar May 15 '20 14:05 voigtd

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

amartyna avatar Dec 10 '20 13:12 amartyna

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>

belloyang avatar Jan 12 '21 17:01 belloyang