How to obtain the android SDK source code and view it in eclipse (for sdk2.3)

Source: Internet
Author: User
Tags server error log

Reprinted from doyee

 

Obtain the Java source code of Android and view the latest method associated with Eclipse: lizongbo published at: 01: 59. Saturday, January 1 st, 2011
Copyright Disclaimer: You can reprint the document at will. During reprinting, you must mark the original source and author information of the article in the form of a hyperlink and this copyright statement.
Http://618119.com/archives/2011/01/01/201.html

The search results obtained by Google for "Android Eclipse source code" are not suitable, because Google's Eclipse Android development plug-in has been updated to ADT 8.0.1. The corresponding lib Method for associating java Source Code has also changed.
Follow these steps to obtain the Java source code of Android and associate it with Eclipse:
1. First download the Android SDK Installation File: http://dl.google.com/android/android-sdk_r08-windows.zip
Decompress the package to: E:/Java/android-sdk-windows, run the SDK Manager.exe in the directory, and download the API packages of different Android versions.

2. Download or install the Eclipse plug-in ADT online,
Installation Package address: http://dl.google.com/android/ADT-8.0.1.zip
Online installation address: https://dl-ssl.google.com/android/eclipse/
Source: ttp: // developer.android.com/sdk/eclipse-adt.html

2. After the ADT plug-in is installed, download the java source code compressed package of Android 2.3 (gingerbread) that I have packaged:
: Http://lizongbo.googlecode.com/files/android_gingerbread_javasrc.zip
Source: http://code.google.com/p/lizongbo/downloads/list
Copy the downloaded file to E:/Java/Android/javasrc.

3. After downloading the android Java source code compressed package, set the SDK configuration in Eclipse:
The operation procedure is as follows: Main Menu-> window-> preferences-> Android, SDK location is set to: e:/Java/Android-SDK-windows, click Apply in the lower-right corner.

4. Start to associate the source code of Android. Create an android project in eclipse, select the project, choose Project> Properties> Android, and select Android 2.3 in Project Build target.
Click "Java build path" on the left, switch to the libraries panel, expand the Lib android2.3, and click android. jar source attachment, and click Edit. in the dialog box, click "external file", select E:/Java/Android/javasrc/android_gingerbread_javasrc.zip, and click OK to confirm. In this way, the Java code of Android is associated.

5. in the same project, select the project, Main Menu-> Project-> properties-> Android, and android1.5, android1.6, android2.01, android2.1-update1, and android2.2 for the Project Build target, repeat the settings in Step 4 above.
In any android project, press Ctrl and click the Java class name to browse the corresponding Java source code.
The source code of each Android version is:
Android1.5 android_cupcake_javasrc.zip
Android1.6corresponds to android_donut_javasrc.zip
Android2.01and android2.1-update1correspond to android_eclair_policrc.zip
Android2.2corresponds to android_froyo_javasrc.zip
Android2.3corresponds to android_gingerbread_policrc.zip

6. Information after source code Association is configured in eclipse will be stored in:
E:/lizongbo/workspacenew/. Metadata/. plugins/org. Eclipse. Core. Resources/. Root/. Indexes/properties. Index
E:/lizongbo/workspacenew/. Metadata/. plugins/org. Eclipse. jdt. Core/variablesandcontainers. dat

At the same time, the android Java source code compressed package is created as follows:
1. Install the following components on the remote Ubuntu Linux Server (linode VPs) (jdk1.6 has been installed ):
Sudo apt-Get install Git-core GnuPG flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
Information from Android official: http://source.android.com/source/download.html
2. Run sudo apt-Get install lib32readline5-dev
3. Install the repo script:
I am too lazy to configure the path, so I directly installed it in/usr/local/bin.
Root@lizongbo.com :~ /Bin # cd/usr/local/bin
Root@lizongbo.com:/usr/local/bin # ls
Geoip-Lookup
Root@lizongbo.com:/usr/local/bin # curlhttp: // android.git.kernel.org/repo>/usr/local/bin/Repo
% Total % received % xferd average speed time Time Current
Dload upload total spent left speed
100 17412 100 17412 0 0 27517 0-:-31148
Root@lizongbo.com:/usr/local/bin # chmod A + x/usr/local/bin/Repo
Note: When downloading the script, you may encounter a server error. The downloaded content is incorrect. When you run the command, the system prompts the error "syntax error near unexpected token 'newline '".
Root@lizongbo.com:/usr/local/bin # repo init-ugit: // android.git.kernel.org/platform/manifest.git-B cupcake
/Usr/local/bin/repo: Line 1: syntax error near unexpected token 'newline'
/Usr/local/bin/repo: Line 1: '<! Doctype HTML public "-// IETF // dtd html 2.0 // en">'
Root@lizongbo.com:/usr/local/bin # More Repo
<! Doctype HTML public "-// IETF // dtd html 2.0 // en">
<HTML> <Title> 500 internal server error </title>
</Head> <body>
<H1> internal server error <P> the server encountered an internal error or
Misconfiguration and was unable to complete
Your request. </P>
<P> Please contact the server administrator,
Webmaster@kernel.org and inform them of the time the error occurred,
And anything you might have done that may have
Caused the error. </P>
<P> more information about this error may be available
In the server error log. </P>
</Body> The content indicates a server error occurs, so you need to download the script again.
4. Create the mydroid directory and download the complete Android source code of the corresponding version by code branch, for example, downloading the android2.3 code:
Root@lizongbo.com :~ /Mydroid # mkdir gingerbread
Root@lizongbo.com :~ /Mydroid # cd gingerbread/
Root@lizongbo.com :~ /Mydroid/gingerbread # repo init-ugit: // android.git.kernel.org/platform/manifest.git-B gingerbread
Root@lizongbo.com :~ /Mydroid/gingerbread # repo sync
Code branch of android1.5:
Root@lizongbo.com :~ /Mydroid/cupcake # repo init-ugit: // android.git.kernel.org/platform/manifest.git-B cupcake
Root@lizongbo.com :~ /Mydroid/cupcake # repo sync
Code branch of android1.6:
Root@lizongbo.com :~ /Mydroid/donut # repo init-ugit: // android.git.kernel.org/platform/manifest.git-B donut
Root@lizongbo.com :~ /Mydroid/donut # repo sync
Code branches of android2.0.1 and 2.1:
Root@lizongbo.com :~ /Mydroid/eclair # repo init-ugit: // android.git.kernel.org/platform/manifest.git-B eclair
Root@lizongbo.com :~ /Mydroid/eclair # repo sync
Code branch of android2.2:
Root@lizongbo.com :~ /Mydroid/froyo # repo init-ugit: // android.git.kernel.org/platform/manifest.git-B froyo
Root@lizongbo.com :~ /Mydroid/froyo # repo sync

If the code download speed is too slow, you can specify hosts. The hosts cannot be configured as follows:
Root@lizongbo.com :~ /Mydroid/gingerbread/. repo/Projects # NSLookup
> Android.git.kernel.org
Server: 72.14.188.5
Address: 72.14.188.5 #53
Non-Authoritative Answer:
Android.git.kernel.org canonical name = android.git.geo.kernel.org.
Android.git.geo.kernel.org canonical name = android.git.us.kernel.org.
Name: android.git.us.kernel.org
Address: 149.20.141
Name: android.git.us.kernel.org
Address: 204.152.191.45
> Exit

Root@lizongbo.com:/etc # vi hosts.
204.152.191.45 android.git.us.kernel.org
204.152.191.45 android.git.kernel.org

An article on the Internet describes how to generate source code packages using the pytho script that extracts and packs java files. For details, refer:

Http://android.opensourceror.org/2010/01/18/android-source/

And http://blog.michael-forster.de/2008/12/view-android-source-code-in-eclipse.html
Python: http://www.python.org/ftp/python/2.6.6/python-2.6.6.msi
However, in the Code of Android2.2 and Android2.3, Android writes mock classes, such as android. webkit. webView: if you use a python script to package the mock source code, instead of the real source code,
Therefore, I wrote a java program based on the python script to extract and package redundant java code for filtering java files.
Generated java source code compression: Compressed
Currently, android_gingerbread_javasrc.zip has been uploaded to code.google.com. you are welcome to download it.

The following are the versions of Android java source:

Android2.3: http://lizongbo.googlecode.com/files/android_gingerbread_javasrc.zip

Android1.5: http://lizongbo.googlecode.com/files/android_cupcake_javasrc.zip
Android1.6: http://lizongbo.googlecode.com/files/android_donut_javasrc.zip
Android2.1: http://lizongbo.googlecode.com/files/android_eclair_javasrc.zip
Android2.2: http://lizongbo.googlecode.com/files/android_froyo_javasrc.zip

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.