17

After a great deal of searchings, I'm can't solve this error when I run:

ionc cordova run android -ls

OUTPUT:

ANDROID_HOME=/Users/lucianokrebs/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
No target specified and no devices found, deploying to emulator        
No emulator specified, defaulting to Nexus_5_API_P

Waiting for emulator to start...

PANIC: Missing emulator engine program for 'x86' CPU.

And the emulator never starts

Also, when I run:

$ ${ANDROID_SDK_ROOT}/tools/emulator -avd my-custom-avd

I got: PANIC: Missing emulator engine program for 'x86' CPU.

But, when I run:

$ ${ANDROID_SDK_ROOT}/emulator/emulator -avd my-custom-avd

the emulator starts and works fine

Seems that the cordova set the wrong path when they try to starts the emulator. Someone already deal with that?

ionic info:
    cli packages: (/usr/local/lib/node_modules)
    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node  : v8.9.4
    npm   : 5.6.0 
    OS    : macOS High Sierra
    Xcode : Xcode 9.3 Build version 9E145 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

p.s: when I run ionic cordova build android its also works fine

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
lucianokrebs
  • 831
  • 1
  • 12
  • 15

9 Answers9

23

From SDK tools version 25.3.0 onwards, the emulator has been removed and moved to ../sdk/emulator.

Just set ${ANDROID_SDK_ROOT}/emulator to your $Path variable so that emulator can be called from the command line and ionic cordova will detect the emulator.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • 1
    Yes! Seems that it fix the problem. For those who are facing the same problem and are coming from the ionic documentation from [macOS setup page](https://ionicframework.com/docs/developer-resources/platform-setup/mac-setup.html), double check this answer – lucianokrebs Apr 02 '18 at 19:41
  • This seems like the answer I'm looking for. But I'm afraid it's not detailed enough to help. How do I update my $path variable, and which part of the macOS setup page does this relate to? – Jesper Bylund Oct 10 '18 at 09:32
  • 1
    @JesperBylund The section on Environment Variables should help.. or check something like https://stackoverflow.com/questions/7501678/set-environment-variables-on-mac-os-x-lion – Suraj Rao Oct 10 '18 at 09:36
  • Is restart required for take effect changing path? – Hamid Araghi May 26 '19 at 15:43
  • 1
    @HamidAraghi not in a mac if you have set in bash_profile.. you need to source it or restart terminal... – Suraj Rao May 27 '19 at 08:16
9

It seems that the above answers worked for you which is great but for anyone else still encountering the error, make sure to check which system image your android virtual device is using (you can check on android studio under the 'API' column in the AVD list).

Check that you're not using anything too new, I tried using 28 and 27 and neither worked but 26 (Android Oreo 8.0) did

Nicholas Xie
  • 121
  • 4
4

For Windows Users:

Just add this to PATH variable

C:\Users\lenovo\AppData\Local\Android\Sdk\emulator
adiga
  • 34,372
  • 9
  • 61
  • 83
4

I had the same problem but adding "sdk/emulator" to my PATH (I'm on Windows) did not work. The reason was that both tools and emulator folders contained an emulator.exe. In the PATH variable, I moved the "sdk/emulator" folder UP, before the "sdk/tools" folder, so that it gets checked first when looking for emulator.exe and it solved my issue.

1

I had the same error

Effectively the @Suraj Rao answer is correctly, but with this changes, my emulator does not run with ionic cordova emulate android. I changed also in the variable enviroment, in my $path this

${ANDROID_SDK_ROOT}\tools\bin

for this

${ANDROID_SDK_ROOT}\emulator\bin

I closed cmd and open again. Then, ionic cordova emulate android runs ok!

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Izas
  • 19
  • 5
0

I tried many of these things and while this may not be the solution for all, I'm sure Windows users could find it helpful...I decided to start over and I ran one of the sample training programs for Kotlin. The instructions provide the set up Android Studio. I ended up with different errors which led to the solution below.

https://codelabs.developers.google.com/codelabs/build-your-first-android-app-kotlin/index.html#1

The problem is related to HAXM. While it's installed in the SDK manager, you must run the Intel program that sits in the SDK folder to fully access it. Browse to:

C:\Users\username\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execution_Manager 

and right click, run as admin, on the file intelhaxm-android.exe FIXED...

bgs
  • 3,061
  • 7
  • 40
  • 58
map
  • 1
0

For Windows Users:

1 - Add this to PATH variable C:\Users\NameUserAccount\AppData\Local\Android\Sdk\emulator

2 - Restart Windows.

0

Simple solution is to first run the android emulator from AVD manager and then start the application on android using "cordova run android" Also, make sure ANDROID_SDK_ROOT is set to path shown in Android SDK Manager (you can check it using Android Studio).

0

Run your virtual device in Android studio and then run the command

cordova run