`tns run android` won't launch emulator


#1

I had Android development working (by going through the standard NativeScript install instructions in the Getting Started guide), but discovered I needed Google Play Services. In my attempts to get that working I messed up my environment somehow. (My playing around included installing Android Studio, but it didn’t work out so I uninstalled it.) Now tns run android won’t launch the emulator (I get “Emulator start failed with: Cannot run your app in the native emulator.”)

I finally discovered that if I run emulator @pixel then the emulator launches and tns run android will find it, install my app, and run it. So I can develop, but it’s awkward.

My debugging turned up the following:
tns doctor reports no problems
echo $ANDROID_HOME gives /usr/local/share/android-sdk
tns device android --available-devices gives

Available emulators
┌─────────────┬──────────┬────────────┬───────────────────┐
│ Device Name │ Platform │ Version    │ Device Identifier │
│             │ Android  │ android-25 │ pixel             │
└─────────────┴──────────┴────────────┴───────────────────┘

tns run android --log trace produces this interesting line:

Starting Android emulator with image pixel
spawn: /usr/local/share/android-sdk/tools/emulator "-avd" "pixel"

but it then hangs.
So I tried running that command by hand and got:

Could not launch '/usr/local/share/android-sdk/emulator/qemu/darwin-x86_64/qemu-system-i386': No such file or directory

Indeed, ls /usr/local/share/android-sdk/ shows that there is no emulator directory. Further, which emulator gives /usr/local/bin/emulator instead of the expected /usr/local/share/android-sdk/emulator (at least, I think that’s what it should be???).

Somehow, it looks like I need to install emulators in /usr/local/share/android-sdk but I don’t know how to do that, or if that will even fix the problem.

Any guesses anyone?
Robert


#2

Try starting the emulator manually before running the project.


#3

Yes, as mentioned, I can do that with emulator @pixel and develop/debug, but it’s an awkward development process. Since I apparently have several copies of android-sdk installed, different tools pick different locations, so I can’t, for example, figure out how to upgrade the SDK.


#4

I’m sorry it sounds like something specific with your machine. Pick one latest installation path and make sure same path is configured on environment variable (Windows) / bash profile (Mac).