Speeding up Android development with Android-x86 and VirtualBox

I’m starting to learn how to develop to Android and so far to me the only downside of the whole dev environment is the painfully slow Android Emulator. Don’t get me wrong, it’s such abeautifullymade emulator that covers most (if not all) details of a real device, I specially like tricks such as limiting network bandwidth to simulate your app under a slow connection, but let’s face it, the thing is slow.

I have to say I don’t have a top of line computer either, it’s a Core 2 Duo with 4gb of RAM running Ubuntu 11.10 (amd64), so I started searching for tricks to speedup the emulator, until I found thatAndroid-x86can be used as a emulator. The experience is not as good as Google’s official emulator but with some tweaks you can really speedup turnaround both in boot time and overall execution speed. OK, TL;DR, enough small talk, let’s get down to business, click the following link to go to the full post

TheAndroid-x86project provides some ISO images that can be ran on VirtualBox (download ithereif you don’t have it yet). I took the time to wrote the steps bellow based on various blog posts about the subject.

First, download an ISO from Android-x86download page, android-x86-2.3-RC1-eeepc.iso should do, this one is pretty stable and has ethernet support. There is a RC1 honeycomb portherebut I didn’t test it.

Now create a VM on VirtualBox, my settings were:

Linux / Linux 2.6,RAM: 256 MB,Fixed Size, 512 MiB VDI Disk

You can play with these options to find which ones fits better with your apps, for me 256 MiB was sufficient

OK, after that you need to setup the ISO file, to do this select your VM from the list and go to Settings / Storage, click on the disk icon and chose a virtual CD/DVD disk file. Select your ISO of choice

Now go to Network, there you have two easy options – If you have a router on your network, select Bridged Adapter and your internet connected adapter (mine iseth1). This is the easiest option in my opinion.

If you don’t have a router or if it didn’t work for any reason, select NAT. Using NAT you can’t connect directly to the device, but thankfully VirtualBox has a handy port forward feature. To use it you just need to click on Advanced / Port forwarding and add a rule like this one:

Note that no matter which mode you choose you need to click in advanced and select PCnet-FAST III as the Adapter Type.

You can also disable the USB controller if you don’t need it.

Now click OK and start up your VM.From the GRUB menu, select Install to Harddisk

Follow screen instructions. From the partition options menu select Create/Modify partitions, this will show you the partition manager (cfdisk), there, using the arrow keys, select New / Primary and specify the size (534.64 for me). Make the partition Bootable and select Write, after that select Quit to go back to the installation menu.

Select the recently created partition (sda1) and click OK. Now format the partition as ext3 and install GRUB.

When the installation asks if you want the system directory as read-write, answer Yes.Installation should not take long. You can create a fake SD card, I created an 128 MiB one. You can skip this step and select reboot.

Now that installation is done you can shutdown the VM, go to settings and remove the ISO from the settings menu, and start it again.

From the GRUB menu above, select Debug Mode to configure the screen resolution, here I created a 480×750 entry to better simulate a smartphone screen. To do this you need to run these commands:

mount -o remount,rw /mntcd /mnt/grubvi menu.lst

This will open GRUB’s menu configuration with the default entries, you need to create a new entry with these options:

title Android-x86 2.3 Smartphone        kernel /android-2.3-RC1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode DPI=160 UVESA_MODE=480x800 SRC=/android-2.3-RC1 SDCARD=/data/sdcard.img

To go to edit mode onviuse the Insert key (to go to insert mode). After inserting the above lines save the file to disk: press Escape (to leave insert mode), then write:wqon the bottom command line.

Now you need to umount the disk and reboot your VM, to do this execute these comands:

cd /umount /mntreboot -f

And Done! Now let’s go to some needed adjustments…

After a couple seconds you’ll be greeted with Android’s home screen. Click on the VM screen, if the cursor don’t show up pressRight CTRL + i, click on the application menu icon and go to Settings. There, enable the Ethernet adapter. To go back to the home screen pressWin Key, to go back one screen pressEsc. To show the options menu pressF2.

If you choose NAT you’re ready to go, if you choose Bridged you need to get the VM’s IP, so pressALT + F1to go to the Busybox prompt and executenetcfg.

Your network configuration will be printed to the console, to go back to the user interface pressALT + F7.

Now you need to connect adb to be able to use the emulator from Eclipse.

Open a console and go to android sdk home/platform-tools, once there execute this for NAT:

adb connect127.0.0.1

If you set networking as Bridged Adapter, execute this:

adb connectyour-android-ip-see-netcfg-step-above

Done with the adjustments

Now go to Eclipse and run your project as an Android Application, if the device selection screen doesn’t show up go to Run Configurations and set the Android Launcher to use Manual selection.

Dpne!(for real this time)

I usually test using the official emulator once just to make sure everything is OK.

You can also download older versions of android from the android-x86 project website to simulate other devices.Hope it helps, if you have any problems let me know in the comments section



---------------------------------------------------------
专注移动开发
Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian

更多相关文章

  1. Android(安卓)(AOPS) 开发环境配置
  2. Android开发笔记: Activity
  3. Android开发调试常用命令
  4. Android(安卓)开发获取手机运行内存工具类
  5. Kotlin简单开发-RecyclerView
  6. 理清 Jetpack 这些知识点后,我面试顺利入职了腾讯
  7. 该出来了吧!2021 年 适合3—5年Android(安卓)中高级开发工程师最
  8. 2020年Android开发市场真的饱和了吗?
  9. 在 Android(安卓)开发中使用协程 | 上手指南

随机推荐

  1. android之知识点小结一
  2. Android布局属性详解
  3. 2013.08.15——— android Fragment的简
  4. 让EditView只能输入电话号码 同时还是密
  5. Android 短信 彩信 wap push的接收
  6. 最新Android ADT, SDK, SDK_tool等官方下
  7. android sms发送、接收及格式
  8. Android布局
  9. [置顶] Android(安卓)性能优化(一)内存篇
  10. Android 布局属性大全