I've recently been getting further into Android development and as most people that have touched the official SDK know, the Android emulator is giant pain in the ass to work with. The reason it is slow is a combination of factors (ARM - x86 conversion, slow screen updates), but fortunately thanks to the Androidx86 project you don't have to live with it any more.
The Androidx86 project aims to port AOSP to the x86 architecture and supply drivers for common devices; it does this well and is getting better with every release. I'm going to show you how to set up the perfect Android VM for development (this assumes you have the rest of the SDK working fine, including access to
adb from the command-line).
To start off we're going to head over to http://code.google.com/p/android-x86/downloads/list and download the iso labelled as "android-x86-4.0-RC1-eeepc.iso" (181MB). While this is downloading you will want to make sure you have a copy of VirtualBox for your platform of choice.
Once this has finished downloading and VirtualBox has been installed, fire up the VirtualBox Manager application and select the "New" button from the toolbar. This launches a wizard to guide you through creating a new VM, simple really.
Give the VM a name of your choice (I simply chose "Android"), select "Linux" as the Operating System, and "Linux 2.6" as the version. Next we'll want to give the VM some memory. Choose whatever is suitable to your setup, but anything greater than 256MB should suffice. Then we're on to setting up virtual hard disks; we can safely uncheck the "Start-up Disk" option (as we're using a livecd) and continue to the next screen. Finally (after dismissing the warnings) you should have a brand new empty VM ready to use.
We aren't quite ready yet though, lets tweak a couple of options before continuing. Right click on your newly created VM and select "Settings". From here navigate to the "Storage" category, and click on the "Empty" under "IDE Controller". On the attributes pane to the right, check the "Live CD/DVD" box, then click on the CD icon and select "Choose a virtual CD/DVD disk file...". Select the eeepc ISO downloaded earlier.
Next jump down to the "Network category", click the "Advanced" dropdown, and change the Adapter Type to "PCnet-FAST III". Now click on the "Port Forwarding" button and add a new entry, setting the Host and Guest port options to 5556. Finally you can close the settings dialog and return to the main screen.
Now we're going to set up a phone resolution (as by default Android-x86 boots in a conventional tablet resolution). To do this, right click on your VM and select "Show in File Manager" (or "Show in Explorer"). Close the VirtualBox Manager and open the .vbox file in your favourite editor and add the following lines under the
<Machine> XML tag:
<ExtraData> <ExtraDataItem name="CustomVideoMode1" value="320x480x16" /> </ExtraData>
Save and close this file, and now we're ready to launch our VM. Open up VirtualBox Manager again and hit start. Once presented with the boot menu, hit the TAB key. Now add
UVESA_MODE=320x480 vga=864 and hit enter to boot. Your VM should resize and boot up to a welcome screen. Press Right-ctrl + I to disable "Host Mouse Integration". Now click inside the VM and work your way through the welcome screen. You can skip pretty much everything that it asks so feel free to do that.
Once at the home screen, open up the apps menu and scroll across to the right until you find "Terminal Emulator". Open it up and then type the following commands:
su (this will popup a dialog, hit Allow) netcfg eth0 dhcp setprop ro.kernel.android.ndns 1 setprop net.dns1 184.108.40.206 adb tcpip 5556 (or whatever port you used earlier) exit exit
Your VM is now set up for network and ADB access. At this point I suggest taking a snapshot of the device by going to the "Machine" menu and selecting "Take Snapshot". Also remember when powering off the VM to select "Restore current snapshot 'Snapshot Name'", so that your VM is always fresh.
If you now open up a command-line on the host, you can type in
adb connect 127.0.0.1:5556 and you should successfully connect to your VM. You will have to do this each time you start your VM, but I don't think it's a big deal.
Running your app within Eclipse will now work as expected and launch inside your VM, at much better speeds than before ;)
Finally, to make this setup perfect, right click on your VM inside the Manager and select "Create Shortcut on Desktop". Now you should be able to start a fresh Android VM in well under 10 seconds (takes about 3 on my PC) and be ready for development!