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.
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.
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.
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.
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.
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.)
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
Wow, I didn't even know about that. I'm not seeing a way to access that - but I may be missing it.
Couldn't find it too!
Ok, maybe the next build will have it.
That's what I'm thinking too
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.
Hmm - but the UI was totally different from the emulator I knew before though.
Yeah, Google got rid of the hardware buttons and keyboard that used to be in the UI a while ago.
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.
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).
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.
Yup--new version is in the Canary channel now.
Did you try it? I'm not seeing anything fancy in the simulator. (Still fast though.)