Android is awesome but its SDK doesn't boundle source jar file. I guess Google just wants to place some mental challenges on us because the instruction of getting source code and making it work inside Eclipse is hard to follow. Well, I found some posts on this issues but I have to combined them together to get it work (unfortunately, none of them works for my case individually). I have a Windows XP (sp3) PC and a Redhat Linux machine (RHEL WS4). Here is my procedure to save people's time:
1. Download Android SDK and install it.
2. Install Git on the Linux machine. (current version is: 220.127.116.11)
3. Goto Linux machine to get the Android source code:
$ mkdir Android; cd Android
$ git clone git://git.source.android.com/platform/frameworks/base android-api
$ cd android-api; git checkout
4. zip all java files under android-api directory but preserve the directory structure.
$ find . -type f -iname "*.java" -print | xargs zip android_src.zip -
I have uploaded android_src.zip (ver 1.0r2) onto my googlepages site. You can skip previous step 2 to step 4 if you use source I built.
5. copy over the created android_src.zip into the Android SDK folder on Windows. Just put it side-by-side with android.jar
6. Inside Eclipse, let's assume you have already loaded Android sample projects correctly and you have android_src.zip source code already. But the Android Eclipse plugin doesn't allow to modify the Java source attachment of android.jar in the Android Library. See Eric Burke's post for detail. But, I just want to do a little different than his approach because it doesn't work for me when I follow his instruction on creating sources folder.
7. Follow the steps:
a. Select the project on Eclipse and right click mouse and choose Properties.
b. Select the Android Library and hit "Remove" to remove it.
c. Hit "Add External JARs..." and select android.jar from Android SDK installation folder. Now, android.jar is treated as the normal jar file.
d. Now, you can go ahead to attach android_src.zip to android.jar just like any other java source attachments for jar files.
8. I have tested it and it works great. Also, if multiple Android projects exist inside workspace, the step 7 only needs to be done for only one project and others just work immediately without any change.