20

I need to look at the .java files of the android sdk. I have developed applications before but I never needed to look at them so it wasn't a problem then. I saw there is a jar file android.jar that contains all the class files structured but actual sources are not there. git gives various problems to me because I am behind a weird proxy so http://source.android.com/source/using-eclipse.html hasn't been very helpful. What should I do?

EDIT: I'm talking about the java files, just to clarify. And in case you are okay with browsing the code online, Where can I find Android source code online? http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/core/java/android/

6 Answers 6

20

Just open the Android SDK Manager and select the Sources for Android SDK of the API level you are trying to support and click Install packages:

(In this case I selected those for SDK v4.3 API-18 and SDK v4.2.2 API-17 but I already have them installed) Eclipse Android SDK Manager

If for some reason you SDK manager button doesn't show up on the Eclipse toolbar, follow this recommendations.

To link the source code to Eclipse just follow this instructions; Android Sources are usually under [ANDROID_SDK_FOLDER]/sdk/sources/android-[API_LEVEL]

Sign up to request clarification or add additional context in comments.

4 Comments

A little late coming to the show, but google is showing up a host of conflicting information on this and this seems a competent enough thread to get the decisive answer. The sources available from the sdk sources plugin are only installable down to and including android 14?
@RichardRiley: That's what you will see on the SDK Manager if you opened id, level 14 is the first level with available Sources installation. Not sure if this is officially documented but that's what I've seen so far.
The procedure above gives me the source to android.jar but not the the android-support-*.jars. Is there a way to get the source to them also?
@Chepech: typo: s/soruces/sources/
4

You can download the ICS sources via the adk manager to your local machine and then attach them to your project in you IDE. See e.g. the blog of Lars Vogel

4 Comments

I'm sorry, I'm not very much familiar with terminologies. Could you provide any link?
is the process different for froyo?
isn't there any way by which I can browse it online?
Browse Lars' blog - I think he also described this for Froyo. And I don't know if this is available for browsing online - you could of course just click through the sources of the android project, but most convenient (in my opinion) is having them accessible from the IDE
2

It is a online latest linux and android source code browsing website.

Android/Linux Source Code Cross Reference http://hala01.com/

Comments

2

You can browse the .java files of the Android SDK here:

http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android

Comments

0

The links in the other 2 answers, http://hala01.com/ and http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android are no longer working.

You can download and view android SDK source code from this site. As of today in October 2021, source code of up to API level 31 is available.

Since such websites may become unavailable in the future, you may want to download local copies for safe keeping.

Comments

0

You can find all Android API source code via the link https://dl.google.com/android/repository/repository2-2.xml

Search for (example) Sources for Android 32 and get the corresponding url value for the right filename. Now you can download it from https://dl.google.com/android/repository/sources-32_r01.zip

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.