Sharing the Code

Programming stuff that might be useful to others

Adding Android’s source to Eclipse

Sometimes it would be nice to click on an Android class and be able to see the source in Eclipse. You could download the source using Git but you then have to rearrange the Java files. The following is the most straight forward way I have found.

  1. Clicking on the link below will download the froyo (Android 2.2) source.
    http://git.source.android.com/?p=platform/frameworks/base.git;a=snapshot;h=froyo-release;sf=tgz
    Change the h parameter for different branches so it matches with the version you have installed with Eclipse. For a list of branches click here and scroll down to “heads”.
  2. Uncompress the downloaded tgz file (WinZip will do if you are on windows).
  3. Drill down into base-froyo-release-adba66b\core\java and zip the android directory. You could delete the aidl files first by going into the android directory and searching for *.aidl files and deleting them.
  4. Open Eclipse, goto Project > Properties > Java Build Path. Under the Libraries tab you should have an Android library. Expand it, then expand the android.jar, select source attachment, press External File… button and then select the zip file you have just made.

Comments are closed