Ionic run android fails

This must be a common question. I have just installed IONIC on windows 7. I get all the way to “ionic build android”, which runs fine. But when I try “ionic run android” for my test project, I get an error:

ERROR running one or more of the platforms: Error: c:\ . . . \ionic\proj1\myApp\platforms\android\cordova\run.bat: Command failed with exit code 2
You may not have the required environment or OS to run this project

Any clue why the last run step should fail? I installed the full Android 22 development environment.

I think this ticket on github is related to your question, check it out

Thanks. I’ll post if and when I have an answer. I was wondering whether it might be a version issue – i.e., the latest Android got ahead of Ionic. However, I haven’t read the complete github entry yet. Will get back later.

The “tab” project I downloaded has an androidManifest.xml file in “project/platform/android” that specifies SDK version 21, but the the Android 22 installer does not automatically install previous versions.

So the first thing I did was install Android 21 using the Android manager.

I still had problems building. Save some JS errors. I upgraded Node from 0.10.32 to 0.12.2, but that didn’t help (but it didn’t hurt).

Then I noticed that I had put “tools” at the end of my ANDROID_HOME environment path and removed that.

That enabled build, but now I am getting an error that there is no emulator in which to run the build with the “ionic run android” command line. But the error messages give some guidance about fixing that. I’ll get back when I fix that.

If this error appears to anyone, it means exactly what it states.

Ionic Team, currently, does not recommend using the android emulator because it is slow, instead, connecting an android device via USB and run and build on the real device for your tests is recommended. This will allow you also to test all the native functionality you have implemented.

Or alternatively, use GenyMotion emulator. If for some reason you have to use android emulator, then you need to create new android devices from the Android AVD manager which you start like so

android avd 

which will open the Android Virtual Device Manager then you can create new ones (Hint: HAXM is required ).