Cordova android emulator stopped working
Solution 1
Just re run after starting emulator manually.
Create Emulator
- type
android
in cmd and hit enter, a GUI will come. - Under tools section click “manage AVDs” and follow the further instruction to create a new AVD.
Start Emulator
-
emulator.exe -avd *avdname*
in cmd (wait for few minutes for full start up) - now re run cordova. it will work.
Solution 2
I Have recieved the same error myself, there may be 3 issues :
the emulator uses the apk file generated in the platforms/android/bin folder. sometimes this is missing so make sure to:
- cd platforms/android
- ant clean
- ant debug
Which will create the missing apk file if missing.
The second issue may have come with adding it to the emulator, which must be run prior:
How to install an apk on the emulator in Android Studio?
There is also the option to delete and create the android virtual machine using:
AVD at http://developer.android.com/tools/devices/index.html
hope this helps, let me know. There is very little documentation about this error.
Solution 3
@Tech Pro
Cordova 3.2 need Android KITKAT version sdk. So, the problem lies in your Android SDK version. There are two solutions of this problem.
Solution:1:
Update your Android SDK to latest version or downgrade to Cordova version 3.0 as suggested by @Evers
Solution:2: If you don't want to either upgrade the Android SDK or downgrade Cordova version then follow the steps here.
- Find the CordovaWebView.java file ({project}\platforms\android\CordovaLib\src\org\apache\cordova)
- Go to Line No-296 and update the code as follows "android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KIT_KAT". Change your version code according to your SDK version from this link http://developer.android.com/reference/android/os/Build.VERSION_CODES.html. Ex: if you have Android 4.2 then chnage KITKAT into JELLY_BEAN.
- Comment out line No-299 i.e. //setWebContentsDebuggingEnabled(true);
- Now follow the steps given by @snake. i.e. ant clean and ant debug. I hope it will work
Solution 4
@Tech Pro This error may be caused by the undocumented fact that the virtual machine needs to be launched + unlocked before the emulate command is sent.
Make sure that a virtual machine has been created by Android virtual device manager by the following command:
android avd
Make sure the versions are correct with the compatibility for your app :) I'm sorry I got the late reply!
Solution 5
I was playing with the Cordova workshop tutorial and ran into a similar issue with the android emulator not starting. I checked the above answer but it still didn't work for me. So here is what I did (I'm using windows 7):
I started the
AVD (Android Virtual device)
manager from:start->programs->Android SDK Tools->AVD
Manager.I noticed the single entry listed for
Nexus_5_API_21_X86
had "?" next to Platform and other columns. This made me wonder why.I click "
Edit
" and specify the target platform, and other missing fields.Click the "Start" to start the
AVD
. After a min, you should also see the android emulator screen display.rerun cordova
(c:\Cordova\workshop>cordova emulate android)
Voila! The command window then displays the compilation progress and finally, you should see the messages below. After another min, you should be able to find your app on the android emulator.
BUILD SUCCESSFUL Total time: 1 mins 10.307 secs Built the following apk(s): C:\Cordova\workshop\platforms\android\build\outputs\apk\android-debug.apk Installing app on emulator... Using apk: C:\Cordova\workshop\platforms\android\build\outputs\apk\android-debug.apk Launching application... LAUNCH SUCCESS
Hope this helps!
Related videos on Youtube
Evers
Updated on June 05, 2022Comments
-
Evers almost 2 years
I'm building an app for Android using Cordova. The android emulator was working fine but I wasn't using it because I installed the Ripple emulator. I continued on building my app, but somewhere the emulator got corrupted.
When I execute the following:
cordova create test cordova platform add android cordova build cordova emulate
Results in the following error:
Error: An error occurred while emulating/deploying the android project. events.js:72 throw er; // Unhandled 'error' event ^ Error: spawn ENOENT at errnoException (child_process.js:980:11) at Process.ChildProcess._handle.onexit (child_process.js:771:34) ]
I have Cordova 3.2 installed and the Android 4.3 API aswell as 4.4. I tried to reinstall Cordova with
npm uninstall cordova
And reinstall it again, but it is still producing the same error. I also reinstalled the Android SDK. This is the log when I run run.bat --emulator:
[ 'adb devices', null, 'List of devices attached \r\n\r\n', '' ] exec: android list avds [ 'android list avds', null, 'Available Android Virtual Devices:\n Name: AVD_for_Nexus_S\n Path: C:\\ Users\\Evers\\.android\\avd\\AVD_for_Nexus_S.avd\n Target: Android 4.4 (API lev el 19)\n ABI: armeabi-v7a\n Skin: 480x800\n', '' ] exec: android list avds [ 'android list avds', null, 'Available Android Virtual Devices:\n Name: AVD_for_Nexus_S\n Path: C:\\ Users\\Evers\\.android\\avd\\AVD_for_Nexus_S.avd\n Target: Android 4.4 (API lev el 19)\n ABI: armeabi-v7a\n Skin: 480x800\n', '' ] WARNING : no emulator specified, defaulting to AVD_for_Nexus_S Waiting for emulator... exec: adb devices events.js:72 throw er; // Unhandled 'error' event
Any clues?
-
Purus over 10 yearsHave Ant installed and configured with path?
-
Evers over 10 yearsYes, Cordova is building without errors
-
-
Evers over 10 yearsThanks, installing the apk manually on the emulator works! So I think it has something to do with the new version of Cordova or the emulator. I'm going to try some things out.
-
Matt Stone over 10 yearsThis worked for me (v3.3.1) - more details here: github.com/phonegap/phonegap-cli/issues/…