Android OS Source Code Modification: Getting Started with Android Source Code modification

I have just started playing with Android OS Source and I can assure you, it can be a real pain for some people, so be prepared.

For all the downloading and documentation needs, you can go to:

We'll be using one key command , repo, to download the OS from the Git repository.
be patient and read the full article, it will explain all.

First of all, you can't play with it on your beloved Windows (to be specific, Android 2.2 Source Code development doesn't support Windows) . you'll have to get a Linux (preferably Ubuntu, as they've used Ubuntu) to work with the source of Android 2.2.

Second, Not all the things written in the documentation are correct. I cam across many anomalies in the documentation, sometimes total contradictions too, so I'll be discussing the real details too.

To download the source code, you'll have to go to this link to get the instructions (While I am also giving them here) ->

Steps to setup developer machine:
  1. You should have a Mac or Ubuntu machine, as Windows is not yet supported. Now here's the catch, the documentation says they haven't tested 64 bit versions of Ubuntu and prefer to have feedbacks, but the reality is, if you are going to work with Android 2.2 or higher, you wouldn't be able to build your source if you aren't running a 64 bit version. so better get the 64 bit version of Ubuntu and follow the steps ahead. and please, do get a hi end system with at least 3 GB of RAM, good 64-bit processor-motherboard and nice HDD space, as while development and building, Android OS becomes a monster in every aspect.

  2. As soon as you finish setting up your Ubuntu 64, you'll have to setup some more things. use this command to get them:

    $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev  gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

    Notice here, there are a lot of packages being installed, but perhaps you won't be able to install sun-java5-jdk  as its not available in Ubuntu repository. You'll have to install it via Sun's website. AND it will also not be supported, as Android 2.2 will require Java6. don't go by the documentation for this. this is why i have written it in strike-through.

  3. Now, install Java6. to ask how this will be done, ask me separately or google for it, as this article isn't about it.

  4. Repo & Git: Repo is a client that fetches the source of Android OS from the git repository. Google guys maintain the code of Android on git, and its updated frequently, so now you'll have to setup repo and fetch the source code.
 Configuring Repo:
  1. To download repo, you'll have to follow some easy steps, follow these lines:
    $ cd ~
    $ mkdir bin 
    $ echo $PATH 

    The last line checks if ~/bin is in your path.
    Now to download repo:

    $ curl >~/bin/repo
    $ chmod a+x ~/bin/repo

    This will download the repo script and will make it executable.

  2. now the next step is to fetch the whole Android code. hold your breath, its of about 2.1 GB, and will take a LONG time! run this command:

    $ ./repo init -u git://

    Notice that the documentation doesn't include a './' before repo in this command, but you'll have to include it in order to run it. this will download the manifest and will set the repo client up, so that when you sync, it downloads the correct thing. It will ask for your name and email, so give it. better if its a Google account, it can be used to submit back the code. The next command will start download:

    $ ./repo sync

    this command will start syncing your current directory (that is ~/bin) with the Android 2.2 git repository. As this process is going to take time, you can go out for a walk or a game.

  3. Every time you run the syncing, it will sync your base code with the code available in the repository, so possible upgrades will happen. It will be good if you follow a good backup policy.

  4. When you're back, the Android OS might have got downloaded by then, and you can begin experimentation with it.

That's it for now. In my next post I'll explain how to setup Eclipse for Android Source modification and how to build the whole OS.

Till then, take care.
and, I love your comments, so go ahead!


    jeet said...


    i have tried all the steps for making sdk from android source code but still it is showing
    "Nothing to be done for `sdk'."

    can you please give me some guid line how it can be done.

    Android app development said...
    This comment has been removed by a blog administrator.
    kirti92lal said...

    Hi, can i run linux through a virtual machine on my 64bit windows laptop?
    will it work properly?

    KiranTamang said...

    @kriti92Ial: yes you can run. use Oracle virtual box or Vmware workstation or vmplayer to run the linux on top of Windows

    siddhartha gunti said...

    Hi. I need to modify and add some of the classes in frameworks. I want to build an app using this modified source.
    Can you point me in right direction?
    Thanks :)

    Sajid Shaikh said...

    Hi Aman,

    Lots of things changed now, this steps also not valid. Need to set access to Google provide you the shell commands that have to execute.

    Please make changes in this accordingly current procedure.