Hi! We're discussing a clarification of the content license; please look over to Current events if you're interested in editing.

Ubuntu VirtualBox Dev Environment

From Htc-linux

Jump to: navigation, search

This page will walk you through installing VirtualBox on a Windows host machine, installing Ubuntu as a guest machine, and configuring the Android development environment.


[edit] Setting up an Android dev environment with Ubuntu & VirtualBox

  1. Download the prerequisites
    1. Download VirtualBox Note: Do not use the Open Source Edition (OSE) if you wish to connect your device to the virtual machine
    2. Download the Ubuntu Desktop 32-bit Edition ISO
  2. Install VirtualBox: Installing on Windows hosts
  3. Create a new virtual machine
    1. Click the New button in the VirtualBox main application window
    2. Create New Virtual Machine: Welcome to the New Virtual Machine Wizard!
      1. Click Next
    3. Create New virtual Machine: VM Name and OS Type
      1. Type the name you wish to use for this virtual machine. I used Android Ubuntu Development
      2. Select Linux from the Operating System drop down
      3. Select Ubuntu from the Version drop down
      4. Click Next
    4. Create New Virtual Machine: Memory
      1. Select the amount of memory you want to allocate to this virtual machine. I recommend at least 1024MB
      2. Click Next
    5. Create New Virtual Machine: Virtual Hard Disk
      1. Ensure Boot Hard Disk is checked
      2. Select Create new hard disk
      3. Click Next
        1. Create New Virtual Disk: Welcome to the Create New Virtual Disk Wizard!
          1. Click Next
        2. Create New Virtual Disk: Hard Disk Storage Type
          1. Select Dynamically expanding storage
          2. Click Next
        3. Create New Virtual Disk: Virtual Disk Location Size
          1. Pick where to put the virtual hard disk. Recommend leaving it in the default location and name.
          2. Select the size of the virtual hard disk. I recommend at least 32GB.
          3. Click Next
        4. Create New Virtual Disk: Summary
          1. Click Finish
    6. Create New Virtual Machine: Summary
      1. Click Finish
  4. Customize the virtual machine
    1. Right click your newly created virtual machine in the VirtualBox main appplication window and select Settings
    2. Setup networking
      1. Click Networking in the Settings Window
      2. Ensure you are on the Adapter 1 tab
      3. Ensure Enable Network Adapter is checked
      4. Select Bridge Adapter from the Attached To drop down
      5. Select your host computer network adapter from the Name drop down
    3. (Optional) Disable Audio
      1. Click Audio in the Settings Window
      2. Uncheck Enable Audio
    4. Click OK
  5. Set the Ubuntu ISO as a bootable CD on the virtual machine
    1. Right click your newly created virtual machine in the VirtualBox main appplication window and select Settings
    2. Click Storage
    3. Select the Empty CD under IDE Controller
    4. Click the folder with a green caret to open the Virtual Media Manager
    5. In the Virtual Media Manager, add the Ubuntu ISO to available CD/DVD Images
      1. Click the Add icon
      2. Navigate to and select the Ubuntu ISO you downloaded
      3. Ensure Ubuntu ISO is highlighted
      4. Click Select
    6. Ensure the Ubuntu ISO is shown under IDE Controller in the Storage Settings
    7. Click OK
  6. Install Ubuntu
    1. In the VirtualBox main application window, double click your virtual machine to start it
    2. The virtual machine should boot in to Ubuntu, follow Step 4 Install it! by clicking the Show Me button.
  7. Update Ubuntu
    1. Click the System menu from the top menu bar
    2. Select Administration
    3. Click Update Manager
    4. When Update Manager starts, click Install Updates
    5. Restart the virtual machine if necessary
  8. Install VirtualBox Guest Additions
    1. Potential workarounds for Guest Additions on Ubuntu 10.4 [1] or 10.10 [2]
  9. Install packages required by Android
    1. Open a terminal window and execute the following commands:
      1. sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
  10. Install Sun Java [3]
    1. Open a teminal window and execute the following commands:
      1. For Android 2.1 Eclair, you need Sun Java 1.5
        1. sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse"
        2. sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse"
        3. sudo apt-get update
        4. sudo apt-get install sun-java5-jdk
        5. sudo update-java-alternatives -l (Verify that java 1.5 installed)
        6. sudo update-java-alternatives -s java-1.5.0-sun (set java 1.5 was not the default installation)
        7. java -version (Verify that java 1.5 is the default installation)
      2. For Android 2.2 Froyo, you need Sun Java 1.6
        1. sudo apt-get install sun-java6-jdk
        2. sudo update-java-alternatives -l (Verify that java 1.6 installed)
        3. sudo update-java-alternatives -s java-6-sun (if java 1.6 was not the default installation)
        4. java -version (Verify that java 1.6 is the default installation)
      3. Java 6 for Ubuntu 10.10 instructions [4]
        1. Some people swear by openjdk
          1. app-get install openjdk-6-jdk
  11. Install the toolchain of your choice and compile!
    1. Building CyanogenMod6 for Supersonic
    2. HTC Linux article on Toolchains

[edit] Tips


[edit] Tools

  • agcc - script wrapping commands for cross-compiling for the android platform
  • droid-wrapper - This wrapper is similar to agcc but all command line arguments will be passed to the compiler and linker (this is important for the software uses configure) and this script supports gcc, g++, and ld.