8

I know I can access android source code from https://android.googlesource.com, but it's hard to select the right git repo if I only know the package and the name of an android class.

Isn't there a way to locate a file in https://android.googlesource.com?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
tbruyelle
  • 12,895
  • 9
  • 60
  • 74
  • If you're working with Eclipse, see the answer for question http://stackoverflow.com/questions/5233640/best-way-to-attach-android-source-to-eclipse – Victor Ionescu Aug 30 '12 at 15:40

6 Answers6

16

Most things you'll want to see can be found under the frameworks/base repo. This includes pretty much all the public and private API classes that make up the Android Java framework.

If you want to be able to browse the source from within Eclipse, you can follow this guide: http://blog.michael-forster.de/2008/12/view-android-source-code-in-eclipse.html

Finally, the Android SDK Reference Search extension for Chrome lets you browse the public API by typing ad into the URL bar, and it adds a convenient "view source" link to each Javadoc page.

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
2

In my opinion today the best way to look into android sources is the github repository :

https://github.com/android/

Public java classes can be found here https://github.com/android/platform_frameworks_base/tree/master/core/java/android

Internal package is here https://github.com/android/platform_frameworks_base/tree/master/core/java/com/android/internal

Resources are here https://github.com/android/platform_frameworks_base/tree/master/core/res/res

Support library https://github.com/android/platform_frameworks_support

tbruyelle
  • 12,895
  • 9
  • 60
  • 74
2

Since 2011 the source code can be downloaded with the SDK Manager (Window > Android SDK Manager)

  • Install package "Sources for Android SDK"
  • Open Properties of android.jar, which you can find in the package explorer below the Android library
  • In "Java Source Attachment", select android/sdk/sources as external folder

Edit: Eclipse seems to regularly scan the external folder for updates. If this annoys you, you can zip the folder into a .jar and then tell Eclipse to look in that jar for the sources. Eclipse will then no longer scan for changes.

marcelj
  • 598
  • 5
  • 14
0

There is an issue raised against Android project for a single .jar file containing the Java sources.

The issue has been declined but the comments are a good source of methods to access the source in Eclipse.

David Webb
  • 190,537
  • 57
  • 313
  • 299
0

You can search for any Android class through https://cs.android.com easily.

DYS
  • 2,826
  • 2
  • 23
  • 34
0

also, this is a very good tutorial on how to get the source in eclipse, without having to mess with any of the repos or anything, it includes zip files of the the source (which might be out of date)

dylan murphy
  • 1,370
  • 1
  • 18
  • 33