This article describes a simple way to view the android source code in eclipse (record it as a memo ). I have seen several methods that are a little tedious, such as: git to the android source code and then use Python scripts to extract andriod. jar source code, or download a package pre-extracted by others (there are issues such as whether the link is still valid, sometimes it is not easy to download, and the latest version is not timely ). This article introduces a more direct and unrestricted method, as shown below:
1. Download the android source code package directly through URL instead of git. The path is as follows:
Http://git.source.android.com /? P = platform/frameworks/base. Git; A = snapshot; H = head; Sf = tgz
Download the file base-head.tar.gz (106 MB at present ). Decompress it to a directory, for example (on my machine ):
D:/droid/base-head
The Source Path corresponding to andriod. jar is (on my machine ):
D:/droid/base-head/base/CORE/Java
2. configuration items
Because the automatically configured Android library usually cannot add source code paths, we need to use our own definition. Open the project properties and create a new user library on the Java build path> libraries interface. For example, name myandroid1.6 and ask the user library to reference your desired Android version (1.6 here. JAR file, and then add the following source code path to the library. Return confirmation.
After you see that the user library you Just configured is no different from the automatically configured Android library except the name and the newly added source code path, you can remove the reference to the automatically configured Android library.
3. End
Check the source code. Everything is fine!
[Update 20120125] for Android 4x, it is easier to obtain the source code: you can download the source code in SDK manager.