Cordova android emulator stopped working

混江龙づ霸主 提交于 2019-12-02 16:44:51
Pradyumna Swain

Just re run after starting emulator manually.

Create Emulator

  1. type android in cmd and hit enter, a GUI will come.
  2. Under tools section click “manage AVDs” and follow the further instruction to create a new AVD.

Start Emulator

  1. emulator.exe -avd *avdname* in cmd (wait for few minutes for full start up)
  2. now re run cordova. it will work.
Ben O

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:

  1. cd platforms/android
  2. ant clean
  3. 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.

@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.

  1. Find the CordovaWebView.java file ({project}\platforms\android\CordovaLib\src\org\apache\cordova)
  2. 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.
  3. Comment out line No-299 i.e. //setWebContentsDebuggingEnabled(true);
  4. Now follow the steps given by @snake. i.e. ant clean and ant debug. I hope it will work

@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!

MaxRelax

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):

  1. I started the AVD (Android Virtual device) manager from:

    start->programs->Android SDK Tools->AVD Manager.

  2. I noticed the single entry listed for Nexus_5_API_21_X86 had "?" next to Platform and other columns. This made me wonder why.

  3. I click "Edit" and specify the target platform, and other missing fields.

  4. Click the "Start" to start the AVD. After a min, you should also see the android emulator screen display.

  5. rerun cordova (c:\Cordova\workshop>cordova emulate android)

  6. 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!

I finally found a work around. I don't know why Cordova 3.2 isn't able to start the emulator automatically on my system, because it does work on my laptop. Downgrading to 3.0 seems to fix the problem:

npm uninstall cordova
npm install -g cordova@3.0.0

My problem was due to the fact that I was running the android sdk manager through a symlink (I had it at usr/local/bin). It started working when I put my $ANDROID_HOME/tools in my PATH and removed the symlinks.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!