Getting Started for Developing for/under Android – Setting up the System

One of the first things that needs to be done before starting developing for a specific platform, is setting up the system, which involves installing Developing Tools, SDKs, etc. Here we are going to describe how to set up a Linux Ubuntu from scratch in order to get started in Android development.


  • Counting on a Host Machine / Virtual Machine (VM) for installing Linux. (VMWare, VirtualBox, Parallels, or any other you can think of).
  • Install Linux in this machine. This tutorial has been tested for Linux Ubuntu 10.10, 11.10 and 12.04, but should be valid for any other distribution (as long as the packages and SDKs we are mentioning here can be successfully installed). Please notice that the OS must be 64-bit in order to compile the Android system.
  • We need to assign at least 4GB of RAM to our VM. 6tGB or higher is recommended for compiling the Android system.
  • The Android system can be also be compiled using Window7 64-bit – This tutorial does not cover it. VMs are your friends 🙂

Now, we are going to set up our system!

Setting up the bottom layer 

We need to install some packages before installing the Android SDK:

  1. Git 1.5.4 or higher
  2. JDK 1.6
  3. flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build- essential, zip, curl, libgl1-mesa-dev

The following commands would do it (First command is to update the repositories):

  • sudo apt-get update –yes && sudo apt-get upgrade –yes
  • sudo apt-get install git-core gnupg flex bison gperf build-essential
  • sudo apt-get install zip curl zlib1g-dev libc6-dev lib32ncurses5-dev
  • sudo apt-get install ia32-libs x11proto-core-dev libx11-dev xsltproc
  • sudo apt-get install lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev
  • sudo apt-get install g++-multilib mingw32 tofrodos python-markdown libxml2-utils

The original source -and therefore where you can get more info- is the Android Open Source Project webpage (here).

After this packages are installed, we need to install:

  1. Sun Java 6
  2. The Libx11 libraries
  3. GCC-4.4

Once again, the following commands should do:

  • sudo apt-get install python-software-propierties
  • sudo add-apt-repository ppa:ferramroberto/java
  • sudo apt-get update
  • sudo apt-get install sun-java6-jdk sun-java6-plugin –yes
  • sudo apt-get install libx11-dev:i386 –yes
  • sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib –yes

Now we need to specify which compiler we are going to use, by means of system variables and save it in our .bashrc:

  • echo “export CC=gcc-4.4 CXX=g++-4.4” >> ~/.bashrc

We re-load our .bashrc

  • source ~/.bashrc

Finally, we install the U-boot tools

  • sudo apt-get install u-boot-tools

Once this is done, the lower layer of our environment is set up. Now we need two more things: (i) a Cross Compiler and (ii) the actual Android SDK.

The Cross Compiler

First, a little reminder: This tutorial is not about developing for Android in terms of Apps. It is about developing for what is UNDER the Android System – which obviously will have an impact on the Apps running on top of it.

This said, when we have a piece of code we want to compile, first we need to now the platform this code is intended to run in .This platform is commonly known as the Target Platform. As for the machine we use for developing/compiling the code that ought to be run in the Target Platform, it is commonly known as Host Machine. The Linux Ubuntu 64-bit machine we have just set up with all the packages above is indeed, our Host Machine.

However, the architecture of the Host Machine and the Target Platform are most probably going to be different and therefore the code compiled in the Host Machine for the Host Machine – which is the case in many cases – will not be compatible with the Target Platform. Here is where we need the Cross Compiler. “A Cross Compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running.” (here)

Each Target Platform needs a different cross compiler, so, based on the embedded system we are planing to develop for, we need to decide which Cross Compiler we use. In our case, we are going to use ARM based processors to run Android, and our choice will be Code Sourcery. Even here, there are several possibilities. For now, we are going to use the Sourcery G++ Lite 2010q1-188 for ARM EABI (arm-none-eabi-). Download here. Please note that you would need to create a free account. After this you should select the IA32 GNY/Linux Installer.

More information regarding the Sourcery G++ Lite ARM EABI can be found here.

Now, we will proceed to install it:

  • cd $DOWNLOAD_DIRECTORY // Typically cd ~/downloads
  • sudo chmod a+x arm-2010q1-188-arm-none-eabi.bin
  • sudo dpkg-reconfigure -plow dash

After this, a window will pop up. Select NO and then press Enter. Continue:

  • ./arm-2010q1-188-arm-none-eabi.bin

Again, a window will pop up and guide you through the installation. You just need to remember:

  1. Choose Install Set > Typical
  2. Choose Install Folder > /opt/CodeSourcery/Sourcery_G++_Lite
  3. Add to PATH? > Modify PATH for current user – THIS IS IMPORTANT
  4. Choose Link Folder > Other: /opt/CodeSourcery/Sourcery_G++_Lite
  5. Install

Now we need to add some lines to our .bashrc:

  • gvim ~/.bashrc //Please note that you might not have gvim. In this case, type: sudo apt-get install vim-gnome

And add the following lines at the end of the file:

  • export CROSS_COMPILE=arm-none-eabi-
  • export ARCH=arm
  • PATH=$PATH:/opt/CodeSourcery/Sourcery_G++_Lite/bin;

Save the document and re-load the .bashrc:

  • source ~/.bashrc

Now, the Cross Compiler is ready to use 🙂

Before we continue with installing the Android SDK, we need to change the permissions on the USB port so that we can directly access it. This feature is normally disabled -for our own security- but since we are going to use our USB to root our platform -among other things- we need to grant ourselves access to them. In order to do this:

  • sudo gvim /etc/udev/rules.d/51-android.rules

And add the command below to the file:

  • SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, MODE=”0666″

Save the changes and exit. After this, we allow all users to access the USB devices. (Note that you can be more restrictive if you want to).

  • sudo chmod a+rx /etc/udev/rules.d/51-android.rules
  • sudo service udev restart

Please note that, if you are using a VM, sometimes you would need to mount the USB on it so that you can access it from you Linux. Refer to the documentation of your VM for this.


As with any other SDK, the Android SDK requires/works-better-and-is-easier an development environment. In our case we will use Eclipse.

We therefore download, and run it:

  • sudo apt-get install eclipse –yes
  • eclipse

Now we need to configure eclipse to work as our Android environment:

  • Workspace: /home/$YOURUSER/workspace > Use folder as default > OK
  • Help > Install New Software
  • Add > Name: indigo, Location:
  • Check “Web, XML, Java EE and OSGI Enterprise Development Linux Tools” > Next
  • Follow the Next > Accept License Agreements > bla, bla, bla > Finish
  • Restart

Once Eclipse restarts:

  • Help > Install New Software
  • Add > Name: ADT Plugin, Location: > OK
  • Check “Developer Tools” > Next
  • Follow the Next > Accept License Agreements > bla, bla, bla > Finish
  • Note that while Installing Software a warning message regarding unsigned content will pop up. Click OK and the installation will continue.
  • Restart

Once Eclipse restarts:

  • Select “Install new SDK” and check the two boxes below it.
  • Target Location: /home/$YOURUSER/android-sdks > Next
  • YES > Finish
  • Select “Accept All” > Install

Now we just need to add the SDK to our $PATH so that we can use it in the command line:

  • echo “export PATH=$PATH:~/android-sdks/platform-tools” >> ~/.bashrc

Re-load .bashrc

  • source ~./bashrc


  • sudo update-alternatives –config jar

For more information regarding the Android SDK and its usage, please refer to the original sources, where most of the information present here has been taken from:

After following this tutorial, our Host Machine (Linux Ubuntu 64-bit) is set and ready for:

  1. Developing for Android – Apps
  2. Cross Compile code for ARM-based processors, on top of which Android will sit on.
  3. Access our physical board via usb by means of Android development tools such as adb

Please notice that some of the information present here comes from paper and code documentation by Hardkernel (, since the board used  for this development has been the Exynos4210 based developer’s board, ODROID-PC

3 thoughts on “Getting Started for Developing for/under Android – Setting up the System

  1. Pingback: The Bootloader – Understanding, Modifying, Building and Installing « My Cellar Door

  2. Pingback: Android Developer Tools – Fastboot « My Cellar Door

  3. Pingback: The Kernel – Understanding, Modifying, Building and Installing « My Cellar Door

Comments are closed.