≡ Menu

Setting up a Android (Froyo) build environment on EC2

I had to prep an EC2 instance for some Android handset build work I’m doing for a client. My VMs weren’t cutting it anymore. This is basically me documenting the quick and dirty steps required to prep an Ubuntu 10.04 instance on EC2 (AMI: be0ffed7).

I’m assuming you have basic knowledge of how to use EC2, but if not, in very very generalized terms (and from memory):

  • Go register for an account
  • Add EC2 to your account
  • Select the EC2 dashboard.
  • Select volumes and create an EBS volume for your build partition.
    • I used a 50G partition
  • Select AMIs and search for the particular flavor of Ubuntu you’re after
    • You may need to change the filters at the top of the results box to get it to display all of the options, I believe it defaults on just your own.
    • I used 10.04 64 bit ami, specifically ami-be0ffed7
    • Make sure its an EBS ami and not an instance image, the difference being the EBS is permanent and your changes will not be lost across reboots
  • Hit the launch button and then answer the questions about the type of machine you wish to run on.
  • You will need to create a set of keypairs used to log in to the machine once its up on the network.
  • You will also probably be asked questions about the security groups at some point during the question and answer process.Â
    • All I did for my EC2 instance was add ssh so I could get into it remotely. For all I know I’ve left a truck sized security hole in the config.
  • Go back to the volumes and associate your build partition with the AMI you just built. It will ask you to assign a device path, I used /dev/sdf
  • At some point on the instances panel you will see that your instance is up and running, select the instance, select actions and pick connect. Follow the instructions and log in.
    • use the user ubuntu and not root.

By now you should be sitting at a prompt on your freshly started instance. Go ahead and label, mkfs, and mount the build volume and then cd into that partition.

I originally used the instance hosts instead of the EBS hosts, so I had to rebuild the environment every time I used the instance. I’d since figured out how to use an EBS ami but I’d done it so often that I’d written the script below to handle installing all the packages that were required. I pulled the java package from java.sun.com.

#!/bin/sh

#update the repos, I had some issues with the ec2 default ubuntu repos, this fixed it.
sudo aptitude update

# any bitness
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

#generally useful for all
sudo apt-get install valgrind

#64bit
sudo apt-get install ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib

#java
echo “Installing already unpackaged java to /usr/local/”
sudo tar -cpvf – jdk1.5.0_22 |sudo  tar -C /usr/local -xpf –

echo “Adding export JAVA_HOME=/usr/local/jdk1.5.0_22 to your .bashrc”
echo “Adding export ANDROID_JAVA_HOME=\$JAVA_HOME to your .bashrc”

echo “export JAVA_HOME=/usr/local/jdk1.5.0_22” >> ~/.bashrc
echo “export ANDROID_JAVA_HOME=\$JAVA_HOME ” >> ~/.bashrc

echo “Updating your path”
echo “export PATH=/build/codeaurora/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/:/usr/local/jdk1.5.0_22/bin:$PATH” >> ~/.bashrc~

Now you should be able to checkout and build whatever flavor of Android you’re working with. I used the froyo-almod from the codeaurora forums.

>>>Karl