4

after initiating the Apache cordova Blank application project template using both under Javascript and typescript. When clicking the debug/run in android device emulator, an error popup as shown below:

enter image description here

I also did the following because it wasn't able to create java virtual machine by registering this: _JAVA_OPTIONS:-Xmx512M

is this a bug or is there a work around?

Additional question: how to let visual studio 2015 ask which android device emulator to use (similar to eclipse) rather than using the first emulator from a list of different emulator created.

vims liu
  • 643
  • 1
  • 9
  • 20
  • Have you tried to clear the cache and run the dependency checker (Tools > Options > Tools for Apache Cordova > Cordova Tools)? – Ali Aug 26 '15 at 19:35
  • Hi, after clearing the cache, and run the dependency checker it says "did not find anything missing or misconfigured components". when I tried running google android emulator (the one that eclipse also uses, NOTE: eclipse is not running) two errors posted which are both "cmd: command failed with exit code 2". – vims liu Aug 27 '15 at 03:36
  • Also, when I changed the error message verbose to diagnostic, this is the full error: the command platforms\android\cordova\clean.bat exited with with code 2 – vims liu Aug 27 '15 at 07:04
  • I also tried repairing the install. NOTE: the java version is targeting 1.8 from the 64 bit folder location – vims liu Aug 27 '15 at 09:39
  • @vims-liu Can you post an image of your Environmental Variables? Tools > Options > Tools for Apache Cordova > Environment Variable Overrides. Can you also confirm that User\...\appdata\local\Android\android-sdk does in fact exist. It's possible you may want to re-install the stand-alone Android SDK. Here's the link [http://developer.android.com/sdk/installing/index.html?pkg=tools](http://developer.android.com/sdk/installing/index.html?pkg=tools) – DeanB_Develop Aug 28 '15 at 13:47
  • Hi, I tried to reinstall the android SDK and just to be sure the jdk Im using, afterwards I am now able to run the project, though it can only deploy to 4.4+ android virtual device. Thanks a lot. – vims liu Aug 31 '15 at 00:59

1 Answers1

1

As mentioned in the comments, this error was solved by re-installing the Android SDK.

Regarding the second question about how to tell Visual Studio to show different emulators in the emulator list - there currently isn't a way to do that. The default Android SDK emulator is a hardcoded choice, and the Visual Studio Emulator for Andoird is also an option if installed. It is possibly to run on other emulators, such as Genymotion, by loading the emulator and then deploying to the Device target (without a device plugged in).

Jordan Matthiesen
  • 1,480
  • 7
  • 17
  • Hi, before marking this as the best answer, I have 1 more question perhaps you know, when I start debug apache cordova for the first time, the android device post a "cannot connect to the server." with an error code -1 (the codes are the same no edit)? also when I open a apache cordova project, from the output window/tab, it says cordova.js not found,(I do understand that cordova.js will be added on runtime), why did it post this error/warning where it will be added during runtime? – vims liu Sep 12 '15 at 23:31
  • Sorry for the late response. I've seen that "Cannot connect to the server" message before and some times it's a result of the adb tool (used for us to connect to a device for debugging) taking longer than usual to startup. Usually running a second works just fine. – Jordan Matthiesen Jan 13 '16 at 17:49
  • And regarding the "cordova.js not found" message - that's good feedback. Like you said, it works at runtime just fine and there's no issue with this message appearing. The reason for it is a side effect of how our JavaScript editor works in Visual Studio. When you reference a JavaScript file in HTML, the JavaScript editor tries to locate and run that file. You're seeing that message since cordova.js doesn't physically exist on disk when you're writing code, but the editor still tries to load it. That's a bug we're aware of, and I don't know yet when/if it will be fixed. – Jordan Matthiesen Jan 13 '16 at 17:51