Making the Android source code available in Eclipse

One of the annoying things in the Android Development Kit is that it does not include the source code for the standard Android classes. This makes it IMHO unnecessary hard to learn the Android platform.

Of course there is a solution for this. Clone the Android Source Code via Git. Once you have the full source code, switch to the “/frameworks/base/core/java” directory, zip the content of the “android” folder and attach it to your Android jar.

For those of you who don’t want to clone the full Android repoI have attached the source from the current version of Android (Android 2.2) here: Android Source Code zip .

I hope this helps.

For further info check my Android tutorial or if you are based in Germany visit my Android Training.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Android, Eclipse and tagged , , . Bookmark the permalink.

12 Responses to Making the Android source code available in Eclipse

  1. Chris says:

    There is an even simpler way: [1] provides pre-packaged Android source bundles (currently for 1.5, 1.6, and 2.1) which just have to be copied into the android-sdk folder (it’s explained pretty well).

    [1] http://android.opensourceror.org/2010/01/18/android-source/

  2. chris says:

    thanks for the tip. i never really figured out where to get the sources. anyhow sometimes you just have to rely on jad ;-)

  3. Haris Peco says:

    I think that you have make two mistakes.
    First, Android 2.3 source isn’t released yet. You are probably make source from master. It isn’t Android 2.3. Second problem is that /frameworks/base/core/java doesn’t contain all classes necessary to debugging (source with all classes is about 30MB size).
    You can take a look Android Sources plugin on http://code.google.com/p/adt-addons/ which adds Android sources of all Android version automatically (except 2.3; will add them when be released) to your all existing and new projects.

  4. Hi Lars,

    why do I need to zip the sources, in order to attach them to the jar? If I keep the sources checked out from the git repo, I could just as well simply specify the folder containing the sources directly, no?

    Regards,

    Wolfgang

  5. Lars Vogel says:

    @All: Thanks for all the corrections. It good that we have more and simpler ways of getting the source.

  6. Haris Peco says:

    Hi Wolfgang,

    The complete Android source is not in one directory and you can’t assign more directories to one container. Because of that you have to make zip/jar which include all Android source directories.

  7. Sanghoon Lee says:

    Is it really android 2.3 sources?
    Where can I get more sources about android 2.3?

  8. Lars Vogel says:

    @Sanghoon no, sorry, was 2.2 (current version in Git). I corrected the description.

  9. Haris Peco says:

    > no, sorry, was 2.2 (current version in Git). I corrected the description.

    The source code in git master branch is not 2.2. Source for 2.2 is in branch froyo. You have set current development code.

  10. Haris Peco says:

    You can get Android 2.2 source with :

    mkdir myfroyo
    cd myfroyo
    repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo
    repo sync

  11. Lars Vogel says:

    @Haris: Thanks for the info.

  12. Lars Vogel says:

    @Haris: I just saw that you contribute refactoring participation to the ADT. Thank is very helpful. Thank you for that.

    Also your plugin from http://code.google.com/p/adt-addons/ is great, I added this to my little Android source description. http://www.vogella.de/articles/AndroidSourceCode/article.html

Comments are closed.