36
C:\hello>cordova emulate android
Running command: C:\hello\platforms\android\cordova\run.bat --emulator
ANDROID_HOME=C:\Users\user\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_10
WARNING : no emulator specified, defaulting to Nexus_5_API_22_x86
Waiting for emulator...

It stays there for ever and does nothing.

sleepless_in_seattle
  • 2,132
  • 4
  • 24
  • 35

19 Answers19

17

I had the same problem. Though cordova started the emulator, the command line kept on saying 'Waiting for emulator...' forever.

The trick is, before running the command:

cordova run android

make sure you navigate into the android platform folder. That is, don't run the command from within the

    /project folder

but instead from within

    /project/platforms/android folder

That will launch your application in the Android emulator

Tomas Antos
  • 284
  • 2
  • 6
17

I did fix it by disabling the AVD Quick boot.

It seems Cordova was expecting an event not sent when the virtual device is re-launched form quick boot.

  • Go into the AVD Manager
  • edit your favorite Virtual Device
  • Show Advanced settings
  • Boot option: Cold Boot
millerf
  • 686
  • 1
  • 8
  • 16
16

I can't guarantee that my problem is exactly the same as yours, but I fix this by simple loading another app on the emulator (e.g. Messenger). At that point the emulator seems to perform some sort of context-menu click inside the app I just loaded and my Cordova app runs fine.

I have honestly no idea why this happens, but this fix works for me.

Chris Rae
  • 5,627
  • 2
  • 36
  • 51
11

Starting the Emulator from the AVD Manager and executing cordova emulate android while the emulator is still running solved the problem for me.

I executed the command from within the /platforms/android folder, like Tomas Antos suggested. Not sure if that had an effect.

Waog
  • 7,127
  • 5
  • 25
  • 37
  • 1
    it solved problem for me too. emulator must be started to start app – Kalreg Feb 01 '17 at 10:25
  • This worked for me, except I ran `cordova run android`. No more `Waiting for emulator to start...` message. The already open emulator loaded my app. – OXiGEN Jul 14 '19 at 21:51
  • omg thanks man.. i couldnt freaking remember what AVD manager was but this helped me lol.. needed to open it from android studio – THE AMAZING Oct 12 '21 at 23:09
9

Found solution for Windows:

  1. Make sure that you have PATH_TO_SDK\emulator in your environment variable PATH
  2. Make sure that it's higher than PATH_TO_SDK\tools

See details to debug if this doesn't work for you:

You can debug by going to platforms\android\cordova\lib\emulator.js and looking for spawn('emulator'. Then, you can log the exact command like so:

console.log(`cd ${emulator_dir}`, '&&', 'emulator', ...args);

In my case, it was:

cd C:\Users\Maxim.Mazurok\AppData\Local\Android\tools && emulator -avd wtg -port 5584

and was giving this error: PANIC: Missing emulator engine program for 'x86' CPU.

After I changed my PATH, it became:

cd C:\Users\Maxim.Mazurok\AppData\Local\Android\emulator && emulator -avd wtg -port 5584
Maxim Mazurok
  • 3,856
  • 2
  • 22
  • 37
  • 1
    This should be the correct answer. Thank you, I can't believe how much time I wasted on this. If you run `where emulator` from a CMD prompt it should list `%ANDROID_SDK_ROOT%\emulator\emulator.exe` before `%ANDROID_SDK_ROOT%\tools\emulator.exe`. Why are there even two `emulator.exe` programs in the SDK? – AlwaysLearning Jul 21 '20 at 23:50
  • @AlwaysLearning thank you :) "the tools/emulator is a work around for older studio" [source](https://issuetracker.google.com/issues/66886035#comment2) – Maxim Mazurok Jul 21 '20 at 23:56
  • @AlwaysLearning - Yup. It's an issue with having an old android SDK installed, and it not being removed after being updated. This is the definitive fix for this issue once and for all. Opening the emulator manually before running the command works too, but this gives the Cordova intended behaviour. – Jack_Hu May 30 '21 at 17:43
8

Have you managed to solve this? If you haven't then, I suggest you to check what are the AVD (Android Virtual Device) available. You might see an error message in the AVD manager. Start all the vitrual devices you see there.

If you get the error:

emulator: ERROR: x86 emulation currently requires hardware acceleration! Please ensure Intel HAXM is properly installed and usable. CPU acceleration status: HAX kernel module is not installed!

Then, open your Android SDK Manager and install intel x86 Emulator Accelerator (HAXM installer) under extras.

That should solve the problem

Kiong
  • 798
  • 1
  • 8
  • 28
4

This question is a little bit old, but I have found another way, if the cli is stuck in:

Waiting for emulator to boot (this may take a while)....

In my case the emulator is already running and I can use the emulated device, but the upload didnt work.

Simply turn the emulated device off by holding the On/Off button until android asks for "Power off". After the shutdown you try booting again and then it worked for me. Hope this helps you in the future.

Arek
  • 89
  • 4
3

I just had that same problem, and after trying many ways, i succeeded by doing this: - Launch AVD Manager, wipe Data and click on Cold Boot Now and wait until emulation is done - Then you go back to your editor and try "cordova run android" again in the terminal. By doing that i got the message :

Using apk: C:\xampp\htdocs\Apps Mobile\xxx\xxxx\platforms\android\app\build\outputs > \apk\debug\app-debug.apk Package name: com.example.xxx INSTALL SUCCESS LAUNCH SUCCESS

and the project app was launched on the emulator.

Thusy V.
  • 41
  • 2
2

What I did to solve and how you can debug yours also

1) Open Android Studio
2) Click Help->Find Action and type "AVD Manager"
3) Create a new AVD using API 26 (at the time of writing this)
4) Once it's created click the play button to try to run it.
5) If it doesn't run it should print an error to the console... you need to resolve every error it prints until you can get it to run via android studio. Once you get it working there it will work with cordova emulate run.

To get mine to work I
1) had add to add a new environment variable called ANDROID_SDK_ROOT and point it to the correct location (in my case D:\Android\android-sdk)
2) Install Intel x86 Emulator Accelerator (HAXM installer) from the SDK Manager
3) Navigate to D:\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execution_Manager and run intelhaxm-android.exe
4) I got an error about hyper-v. IF YOU RUN DOCKER YOU HAD TO INSTALL HYPER-V. YOU NEED TO DISABLE IT TO RUN THE ANDROID EMULATOR!!
5) Once I disabled hyper-v and redid step 3 my emulator worked!

Ashley
  • 422
  • 6
  • 18
1

Here is what I did to solve mine:

  1. When the simulator launches, go to the open apps (in the android emulator), and close everything there. Chances are, cordova has launched at least once before, and this running instance prevents it from launching again.
  2. Exit the emulator.
  3. Cancel the command line and then try to launch the app again.
John Doe
  • 1,364
  • 1
  • 12
  • 19
1

I have followed what Kiong answered.

Sharing all my steps (with prints), in my case I opened Android Studio and then, in the menu, navigated through Tools -> Android -> AVD Manager.

As seen at the image below, I had a message that "Android Emulator is incompatible with Hyper-V."

enter image description here

I have followed the steps suggested (as below):

Unfortunately, you cannot have Hyper-V running and use the emulator. Here is what you can do:

  1. Start a command prompt as Administrator
  2. Run the following command: C:\Windows\system32> bcdedit /set hypervisorlaunchtype off
  3. Reboot your machine.

After the system reboot, I opened the same window (AVD Manager), and a next warning was available, to install HAXM:

enter image description here

After that, the emulator started, but very slow. The next suggestion was to install a better emulator using x86 which gives better performance in my machine (10x faster):

Google Play Intel x86 Atom System Image (system-images;android-24;google_apis_playstore;x86)

enter image description here

I shared the same answer here too.

mqueirozcorreia
  • 905
  • 14
  • 33
1

The only thing that worked for me was opening the emulator first of all. With the emulator opened I run the command: cordova emulate android. "LAUNCH SUCCESS".

leonardofmed
  • 842
  • 3
  • 13
  • 47
0

You can use emulation only in debug mode. Perhaps are you on release mode? Use

console>cordova build --debug

AND THEN

console>cordova emulate android
Ademus
  • 23
  • 3
0

In my case the problem was easy. I don't know if you are using emulator or real device connected to the PC. I'm using Samsung phone instead of emulator and it was also stacked on "waiting for emulator...", but in my case the solution was easy - phone was connected to the cable but the cable was corrupted and PC didn't see the phone and was trying to run emulator :]

The simplest solution is always the hardest one...

Piotr Kowalski
  • 338
  • 4
  • 14
0

My situation was that a command window would briefly appear and then close. However, I could get the app to run if I manually started the emulator through the AVD manager. Watch where the environment variable ANDROID_HOME is pointing to. I had multiple copies of the sdk installed. I upgraded the sdk and pointed the environment variable to it and that resolved the problem.

CarbonMan
  • 4,350
  • 12
  • 54
  • 75
0

After waiting an eternity on "waiting for emulator to start..." on Windows 8 I:

A. I open Android Studio and realized none of the System Images for my Android version were actually not installed because when I originally installed Android Studio I was on a VPN that blocked the download unbeknownst to me. After disconnecting from the VPN and reinstalling Android Studio the System Images installed and I moved on to Step B below.

B. per: this

1) Open SDK Manager (In Android Studio, go to Tools > Android > SDK Manager) and Download Intel x86 Emulator Accelerator (HAXM installer) if you haven't.

2) Now go to your SDK directory C:\users\%USERNAME%\AppData\Local\Android\sdk\extras\intel\Hardware_Accelerated_Execution_Manager\ and run the file named intelhaxm-android.exe.

In case you get an error like "Intel virtualization technology (vt,vt-x) is not enabled". Go to your BIOS settings and enable Hardware Virtualization.

3) Restart Android Studio and then try to start the AVD again.

It might take a minute or 2 to show the emulator window.

0

For me the problem was the device. I changed the Nexus 5 for Pixel and now works fine.

Tested all the above solutions and didn't worked.

Angel Luis
  • 487
  • 2
  • 5
  • 19
0

I had to uninstall the existing app. After that, I could install it again.

tokyodrift
  • 51
  • 9
0

I know this topic is old, but I just got this problem and for me the solution was very simple. I had to remove the AVD and add it again. After that I was able to run the cordova command with no problem at all.

So just go to the Android Studio > AVD Manager > Remove the AVD that is not booting up > Add a new AVD > Run the command again

Make sure to have VT-x ON, Gradle Installed, Android SDK from the project installed, HAMX Installed and etc.

Daniel M. Melo
  • 118
  • 1
  • 6