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/

Community
  • 1
  • 1
prongs
  • 9,422
  • 21
  • 67
  • 105

5 Answers5

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]

Community
  • 1
  • 1
Chepech
  • 5,258
  • 4
  • 47
  • 70
  • 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? – RichieHH Jan 16 '14 at 12:33
  • @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. – Chepech Feb 20 '14 at 18:02
  • The procedure above gives me the source to `android.jar` but not the the `android-support-*.jar`s. Is there a way to get the source to them also? – Lii Apr 15 '14 at 19:54
  • 1
    @Chepech: **typo**: s/soruces/sources/ – pevik Oct 13 '15 at 13:44
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

Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
  • I'm sorry, I'm not very much familiar with terminologies. Could you provide any link? – prongs Jan 12 '12 at 08:43
  • is the process different for froyo? – prongs Jan 12 '12 at 08:45
  • isn't there any way by which I can browse it online? – prongs Jan 12 '12 at 09:00
  • 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 – Heiko Rupp Jan 12 '12 at 10:01
2

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

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

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

a4vi2r
  • 101
  • 1
  • 5
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.

auspicious99
  • 3,902
  • 1
  • 44
  • 58