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.
- Clicking on the link below will download the froyo (Android 2.2) source.
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”.
- Uncompress the downloaded tgz file (WinZip will do if you are on windows).
- 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.
- 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.