Important update for Apache Cordova and Android

This post is more than 2 years old.

Those of us who work with Apache Cordova are well aware of the issues surrounding the Android simulator. Calling it "slow" does not properly describe the painful experience of actually trying to use it. In fact, every now and then when I accidentally launch it via the Cordova CLI, I say something out loud that I don't usually include in my blog posts. (Hint - it rhymes with duck.) How bad is it? I've actually recommended folks go out and buy cheap Android devices instead of using the simulator. Of course, you should always test on real devices. My point is, I'd suggest using a real device instead of the simulator since it was actually slower than going to the real device. Of course, even when I have a real device, half of my USB cables don't properly let adb connect to it. Apparently I'm using the "wrong" USB cables. This is why I use iOS about 99% of the time for my Cordova work. I also recommend Genymotion - a free/commercial Android simulator.

Anyway, this past week Google announced the beta release of a new version of Android Studio. Android Studio is an IDE specifically for building Android applications. It is free, and kinda nice in the few times I've used it. As part of the update, the emulator was also improved. I didn't pay much attention to this because "much improved slow crap" doesn't really entice me, but then I came across this article: The new emulator in Android Studio 2.0 is 50 times faster than before. 50 is a big number so I figured, let me check it out.

First off, it was a bit hard for me to actually find the beta download. You can find it here on Android Studio's Canary channel. I downloaded and installed the bits. I fired up the app and went to Tools/Android/AVD Manager.

shot1

I had one pre-existing AVD that was marked as needing repairing, so to make things easy I just deleted it and created a new one. Over all, the UI is a bit refresher and easier to use, but I pretty much just took defaults for my new device.

shot2

Anyway, I then dropped down to the CLI, made a new Cordova project, added Android, and told Cordova to emulate it. Surprise surprise, the new emulator popped up just fine. I suppose that is to be expected, but it was nice to see it work well.

shot3

The first launch is still not exactly speedy compared to iOS, but as I've seen it take 5 or so minutes in the past, it was a heck of a lot faster. The second launch was really speedy - I'd say less then 10 seconds - on par with Genymotion. (I haven't done scientific testing, but I figure once you get below 10 seconds, it doesn't much matter.) Genymotion though has additional benefits on top of the simulator though so you still want to check it out.

Thanks go to Mike Hartington for letting me know the new emulator worked well with Cordova, and even more thanks to Mike for sharing a video of this in action.

As an additional FYI, it can be a bit difficult to control the Android simulator in terms of rotation and stuff like that. The program menus for it are pretty much completely blank. I Googled around a bit and found results to help: Android Emulator Shortcuts. But I'm surprised the app itself seems to provide no help.

Anyway - if you've avoided the Android emulator like the plague over the past few years, it's time to finally give it a shot again.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Dave Ferguson posted on 11/25/2015 at 3:57 PM

Just a quick note as I ran into this. The tools menu doesn't show the "Android" submenu until after you build the apk for the project.

I will agree that the emulator is much faster. I didn't see your sub 10 second launch but I did see it below 30 seconds. Considering it used to take minutes that felt like hours I would consider this a win.

Comment 2 (In reply to #1) by Raymond Camden posted on 11/25/2015 at 4:58 PM

Dave, thank you! In my 'real' testing, I actually built an Android app first using a default new project. I did that just for the heck of it and I didn't think it really mattered, so thanks for sharing that.

I have to wonder if you could also launch the emulator via the Android CLI. (Specifically the emulator command.)

Comment 3 by Tolu Olowu posted on 12/2/2015 at 8:26 PM

Hi Raymond, do you know if the android emulator in studio 2 preview has all the features demoed at the dev summit, such as the 'extended controls' panel? See picture here - http://techcrunch.com/2015/...
I installed but that panel isn't in my build or I'm I not doing it right?. Thanks

Comment 4 (In reply to #3) by Raymond Camden posted on 12/3/2015 at 3:06 PM

Wow, I didn't even know about that. I'm not seeing a way to access that - but I may be missing it.

Comment 5 (In reply to #4) by Tolu Olowu posted on 12/4/2015 at 2:43 PM

Couldn't find it too!

Comment 6 (In reply to #5) by Raymond Camden posted on 12/4/2015 at 2:48 PM

Ok, maybe the next build will have it.

Comment 7 (In reply to #6) by Tolu Olowu posted on 12/4/2015 at 3:34 PM

That's what I'm thinking too

Comment 8 by John Kemnetz posted on 12/4/2015 at 8:56 PM

I think you're actually just seeing the old emulator from Google, but with Intel HAXM running. The new emulator isn't a part of the canary channel yet (per what Google said at the Dev Summit) and has a different UI from the one shown above.

Comment 9 (In reply to #8) by Raymond Camden posted on 12/4/2015 at 8:58 PM

Hmm - but the UI was totally different from the emulator I knew before though.

Comment 10 (In reply to #9) by John Kemnetz posted on 12/4/2015 at 9:17 PM

Yeah, Google got rid of the hardware buttons and keyboard that used to be in the UI a while ago.

Comment 11 (In reply to #10) by Raymond Camden posted on 12/4/2015 at 9:18 PM

Fascinating - so I wonder if what I'm seeing is just HAXM, as you said. I tried HAXM about a year ago and it just didn't work for me.

Comment 12 (In reply to #11) by John Kemnetz posted on 12/4/2015 at 9:29 PM

That would be my guess... the current emulator now forces you to use HAXM--it won't launch at all if HAXM isn't installed and available (for x86 images).

Comment 13 (In reply to #12) by Raymond Camden posted on 12/4/2015 at 9:30 PM

Hmm, well, I still feel good about this post - even though I may have been mistaken. And if it gets even faster, well, that's pretty cool.

Comment 14 (In reply to #13) by John Kemnetz posted on 12/11/2015 at 7:06 PM

Yup--new version is in the Canary channel now.

Comment 15 (In reply to #14) by Raymond Camden posted on 12/11/2015 at 7:25 PM

Did you try it? I'm not seeing anything fancy in the simulator. (Still fast though.)