New setup: AVDs won't start


#1

Hi, just trying to get started here with NativeScript and Angular on a Mac. I followed all the setup steps until I got to tns run android. At that point the guide says I need at least one AVD, so I install Android Studio and create one. When I try to launch it, it says “Starting AVD…” on the bottom of the main Android Studio window and there’s a progress bar that takes about five seconds to complete. When it completes, nothing happens. I’ve tried many different options for configuring new AVDs, and they all have the same result.

I tried creating a new user profile on the computer and first installing Android Studio and creating an AVD (before doing anything with NativeScript) and I was able to launch the AVD successfully. Then I went through the NativeScript setup, and then got the same as before - AVDs won’t launch. So it appears something I’m doing when installing NativeScript is causing the AVDs not to work. Help?


#2

I have the exact same problem and I could not figure out how to solve it yet.


#3

check your ~/.bash_profile

your path needs to point to your android sdk for android studio, you’ll find if you’ve installed the sdk part of the nativesrcript install as well as android studio, you’ll then have the sdk installed twice, which i recommend you don’t install via natvescript, manually install the android studio (as you may need it at some point) and select no during nativescript install.

in ~/.bash_profile update the the ANDROID_HOME path to your android sdk… you can get the SDK location under the android studio SDK manager (it’s under your user directory path)

change:
ANDROID_HOME to ANDROID_SDK_ROOT and point the sdk under your user path (see android studio).

add this to your ~/.bash_profile after ANDROID_SDK_ROOT line.

export ANDROID_HOME=$ANDROID_SDK_ROOT

and add:

export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:

reboot and try again from within android studio to run the emulator.


#4

That worked! Thank you. I hope the docs can be updated to include this. Right now the setup doc doesn’t mention Android Studio or how you’re supposed to install it. It’s also not mentioned in chapter 0 or chapter 1 of the Angular/NativeScript setup guide. There is a link from chapter 1 to the AVD setup doc, but that assumes you already have Android Studio.


#5

Something else worth adding.

Running the emulator from the command line will fail launching an avd.

for example.

running:

emulator -list-avds

will list all avds… like:

$ emulator -list-avds
Nexus_5X_API_23_6.0

this will fail when trying to run it:

$ emulator -avd Nexus_5X_API_23_6.0
[140736508519360]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at …/emulator/lib64/qt/lib
Could not launch ‘/Users//…/emulator/qemu/darwin-x86_64/qemu-system-i386’: No such file or directory

do this instead:

$ANDROID_SDK_ROOT/tools/emulator -avd Nexus_5X_API_23_6.0

when you CTRL-C to get the command line back, the emulator terminates.

append & (background) on the end of the command to ensure you don’t block the command line, like so:

$ANDROID_SDK_ROOT/tools/emulator -avd Nexus_5X_API_23_6.0 &

that should allow you to manually select and invoke an android avd of your choice and regain access to the command line.


#6

The docs are open sourced, there is a great blue ‘IMPROVE THIS ARTICLE’ button below each. Feel free to contribute with your findings and your suggestions in an effort to make the docs better for everyone else.

Thank you.


#7

I’m not sure I know the right way to improve it though. I don’t know whether I really did need to install Android Studio, for one. And it seems like there must be a better way than to install the SDK twice and then edit .bash_profile to point to the right one.