Wednesday, February 8, 2012

Setting up x86 Android with Eclipse


In addition to using emulators and real devices to test your Android apps, you also have the option of running x86 Android in VirtualBox.  In this post, I will describe the steps for setting up x86 Android in VirtualBox, and using Eclipse to push apps onto the VM.  I am performing this installation on Mac OS X.




I. CREATE THE VIRTUAL MACHINE


    1. Grab the iso from www.android-x86.org.


        On the left-hand side there is link to downloads.  I am 
        currently targeting Froyo, so I downloaded 
        android-x86-2.2-r2-eeepc.iso.


    2. Create a new VM in VirtualBox


        $ open -a VirtualBox &


        Click 'New'


        For 'OS Type', enter:
            Operating System: Linux
            Version: Other


        The rest of the configuration is really up to you.  The one        
        exception is that you'll want to create a bootable hard  
        disk.


    3. Mount the ISO


        Now that you've created a VM, you want to insert the ISO 
        disk into it's virtual DVD tray


             Settings > Storage section > IDE Controller


        You should see a CD icon that says 'Empty'.  Select the CD 
        entry and another CD icons will appear on the right of the 
        screen.  Click this latter icon and and select 'Choose a 
        virtual CD/DVD disk file...'.  Enter the path to your .iso 
        disk into the dialog box that pops up.


    4. Install x86 Android onto your VM


        When you first boot up, you will a screen that has a few   
        options.  Choose  'Installation - Install Android x86 to 
        hard disk'.


        Create a new primary partition that is the full size of 
        your virtual hardddisk.  You will want to select the 
        'Bootable' option, and then actually create the partition 
        by selection 'Write'.  The partition created is sda1.


        Select 'Quit'.  


        Now you must format a filesystem on the sda1 partition.  
        Choose ext3.  Also, choose to install the GRUB boot loader.  
        Finally, for development purposes, specify that /system be 
        read-write.


        You can now run the VM.


    5. Unmount the .iso


        After installation, shut down the VM.  Go into settings and 
        unmount the iso.




II. CONFIGURE THE VM'S DISPLAY TO REPLICATE A PHONE'S DISPLAY


    1. Define custom resolution modes


        $ VBoxManage \
        > setextradata "<vm-name>" "CustomVideoMode1" "320x480x16"
        
        $ VBoxManage \
        > setextradata "<vm-name>" "CustomVideoMode2" "640x960x16"
        
        $ VBoxManage \
        > setextradata "<vm-name>" "CustomVideoMode3" "480x720x16"


    2. Modify grub configuration to use these resolution modes


        Start the VM.  When the VM is up, hit <FN-OPTION-F1> to 
        switch to a terminal.  At the shell, remount the boot 
        partition to read-write:


            $ mount -o remount,rw /mnt


        Next, open the grub menu confiruation for editing:


            $ vi /mnt/grub/menu.lst


        Create a new first entry by copying the current first entry 
        and changing it to:


         title Android_x86 2.2.2 (Phone)
         quiet root=/dev/ram0 androidboot_hardware=generic_x86 ...
         acpi_sleep=s3_bios,s3_mode DPI=240 UVESA_MODE=480x720 ...
         SRC=/android-2.3-RC1
       
         I'm using '...' to denote a continuation of the line.


    3. Shutdown the VM




III. PRESENTING VM AS A DEVICE TO ECLIPSE


    1. Get the IP address of the VM


        Start the VM and hit MFN-OPTION-F1> to drop to a shell.  
        Enter the command 'netcfg', and record the IP address.


    2. Connect to VM with adb


            $ adb connect <vm's ip>

No comments:

Post a Comment