Tired of the slow Android emulator on PC?

Monkey Targets Forums/Android/Tired of the slow Android emulator on PC?

DruggedBunny(Posted 2011) [#1]
The Android SDK emulator is notoriously slow, and almost everybody hates it. I recently decided to look into whether I could build Monkey apps for the Android-x86 platform running in a virtual machine, and, by golly, it works!

Although still not running at full-speed (there's no OpenGL acceleration on the android-x86 platform yet, but VirtualBox will support it whenever it appears), it's much, much faster than the SDK emulator. You can also save your emulated machine's state (hit VirtualBox's close button, then choose Save the machine state) so you don't have to boot up each time, though the Android-x86 bootup time is actually not bad at all.

Note that all of this assumes a Windows host PC! VirtualBox is available for OS X as well, but some steps will be different in terms of obtaining your IP address, opening/navigating command prompts, etc.

I followed the steps in post #38 here, but in more detail...

Installation:

· Install VirtualBox;
· Download Android-x86 -- people recommend using android-x86-2.2-generic.iso;
· Install Android via this guide. Just follow the scary-looking stuff in Step 6 to the letter and you'll be fine, though I set the system directory to Read/Write.
· IMPORTANT: BEFORE you run the emulated Android system, do the networking check/setup below! (Only needs to be set once, not on every run.)

VirtualBox-specific tips:

· Every time you boot up the emulator, right-click on the icon second in from the right (at the bottom of the VirtualBox window) and choose Disable Mouse Integration -- unfortunately, there's no GUI-based option to set this permanently for some strange reason;
· To get your mouse back out of the emulator window, press Right-Ctrl.

Networking setup - important:

If you have a router connecting your PCs to the internet (or local network), set the VirtualBox machine's network mode (under Settings) to Bridged and just accept the defaults in that page, so that your main PC and the emulated PC have IP addresses in the same range. (If you're not using a router, my networking abilities run out really fast here, so others may need to assist.)

To check your main PC's IP address, open a command window (Start Menu -> Run -> cmd, or Start Menu -> [Search box] -> cmd) and type ipconfig. Make a note of your Ethernet/Wifi/LAN adapter's IP address (IPv4); it will usually look like one of the following, but not always:

Example IP addresses:

192.168.0.x
10.0.0.x


To check the emulated PC's IP address, hit Alt-F1 and type netcfg. Note the IP address that isn't 127.0.0.1.

The first three numbers of each machine's IP should be the same, eg. my main PC is 192.168.0.2 and the emulator is 192.168.0.3. If they're not the same, communication from the main PC to the emulated PC won't work and you'll probably need assistance from someone with more networking ability than me!

If they are the same, type ping [other machine's IP] from each machine, and you should get a response; if not, check firewall, anti-virus, etc. Ctrl-C will stop pinging on both machines, though Windows only does four pings by default.

Hit Alt-F7 to get back to the main Android display.

To build onto the emulator:

· Before you build your project, open a command window;
· Navigate to your android-sdk-windows\platform-tools folder;
· Type the following, but replace the IP address below with YOUR VirtualBox machine's IP address:

    adb connect 192.168.0.xxx
    


If that fails, later versions seem to need this instead:

    adb connect 192.168.0.xxx:5555
    


· Wait a couple of seconds, until it returns the flashing cursor to the command prompt;
· From MaxIDE, do a Build and Run. You should then find Monkey Game in the Android menu if successful.

Keep the command prompt open -- I have to re-run the adb command each time before I build and run from MaxIDE. (Hit Up cursor followed by Enter in the command prompt to avoid re-typing.)

It's quite a bit of work, but this works for me, anyway, and is a huge improvement!

Meant to add, in your Android project's CONFIG.TXT file (under "projectname\projectname.build\android"), set the SCREEN_ORIENTATION line to SCREEN_ORIENTATION=landscape. You only need to do this once, unless you delete the build folder at any point.


Samah(Posted 2011) [#2]
Nice work! I've yet to try it since I deploy straight to my phone/tablet though.
If only there were an x86 build for Honeycomb!


Vignoli(Posted 2011) [#3]
Hello

Thanks for this helpfull tutorial :-)

I have two question :

1) Under windows 7, i can't get VirtualBox and Android x86 to give sounds.
I've searched under google, but i can't find anything to configure.
An idea of what i can do ?

2) I have a real eeepc 701, a good solution to make screen rotations... do you think i can use it as an android ? ...
If yes, can i connect the eeepc an create a network with a simple USB cable ? (or must i use RJ45 ?)

Thanks

EDIT: Finally, the eeepc 701 is connected via wlan0 and works. :-)


DruggedBunny(Posted 2011) [#4]
Hi Vignoli,

I don't know enough to answer, unfortunately. I tried setting the VM to use a different audio device but that made no difference -- it might just be that Android can't support the emulated audio devices at this point.

Did you get Monkey to build on to your EeePC after all?


slenkar(Posted 2012) [#5]
make this a sticky :)