Where can I find Android source code online? [closed]
Asked Answered
V

7

664

Where can I browse the source code for any Android Open Source Project (AOSP) application (for example the Contacts application)? Is the only way to clone the entire source repository for all of AOSP?

Vermouth answered 16/1, 2009 at 7:31 Comment(6)
You can always use this plugin for Eclipse to view android source: androidpolice.com/2011/12/22/…Officer
I cant find Android API source at Google code search anymore. Maybe grepcode.com/project/repository.grepcode.com/java/ext/… is helpful.Fungistat
@xtr, that's exactly the one I have recently found and was using. They shut down Google Code Search but provided links to a few other resources at that link.Bastia
Source code for all Android versions is here: android.googlesource.com/platform/packages/apps/Contacts.git/+/…Slipknot
You can go to androidxref.com and search for whatever you want.Wilinski
You can get and browse the android source here : zgrepcode.com/android with IDE experience.Ambulate
S
336

Everything is mirrored on omapzoom.org. Some of the code is also mirrored on github.

Contacts is here for example.

Since December 2019, you can use the new official public code search tool for AOSP: cs.android.com. There's also the Android official source browser (based on Gitiles) has a web view of many of the different parts that make up android. Some of the projects (such as Kernel) have been removed and it now only points you to clonable git repositories.

To get all the code locally, you can use the repo helper program, or you can just clone individual repositories.

And others:

Steffie answered 16/1, 2009 at 7:58 Comment(12)
It seems it is not available anymoreSlobber
@Slobber - it is a temporary thing due to the recent hack on kernel.org while they verify the repositories.Steffie
It's still not available over a month laterZaccaria
@Jim kinda worrying - kernel.org is back, but the android repos are not. Maybe they're waiting for the icecream-sandwich open sourcing!Steffie
It seems they killed off android.git.kernel.org definitively. It now redirects to developer.android.com page telling you how to download the sources, which refers to android.googlesource.com, but that does not seem to provide online browsing, only download. The github mirror is still there, but does not seem to be updated.Sweep
Indeed, the github mirror is old. Pull source like so: git clone https://android.googlesource.com/platform/frameworks/base.gitAeonian
As of Dec 10 2011, the GitHub mirror seems to be updated real time. I can see commits which were made a few hours back.Markusmarl
The github repo is incomplete. Today I can't see the libcore project for example. git.omapzoom.org has everything.Yarndyed
@Jesse updated with the link, that is great. The other day I was looking for the platform/sdk and couldn't find it anywhere online.Steffie
Looks like a lot of code is available at: code.metager.de/source/xref/androidCurriculum
How do I make the code I get from those repositories work? I've tried to import them and found so many compilation errors (more than 1000)...Gnash
There is now cs.android.comBamberg
F
68

2020: The official AOSP code search https://cs.android.com/


You can view the source code through http://developer.android.com, when you're reading the API there will be a link to the matching source code on GitHub, you just need to add the Android SDK Reference Search Plugin on Chrome.

I blogged about it here:
http://blog.blundellapps.com/add-source-code-links-to-android-apis/

enter image description here

Flinn answered 18/2, 2012 at 13:14 Comment(0)
B
44

I stumbled across Android XRef the other day and found it useful, especially since it is backed by OpenGrok which offers insanely awesome and blindingly fast search.

Burck answered 4/4, 2012 at 6:13 Comment(5)
It appears to be missing some files. For example, the Android 4.3 CDD specifically calls out /data/misc/sms/codes.xml on page 34. A search of the path results in not found, and a search of the file only returns near hits.Nutgall
@noloader: I think this file is expected to be put on specific device implementations, but does not exist in AOSP. See here for the AOSP code that gets activated when such a file is put on the device: androidxref.com/4.3_r2.1/xref/frameworks/base/services/java/com/…Burck
Yes it is insanely fast but I dont see kernel folder in the source code. Any reason for this?Monte
Not sure who's idea it was to close this good question as off-topic. Android XRef seems to be not updated anymore, you can get the same and even better now on aosp.opersys.comCouloir
Answering this in 2023 for android 14 code base: aospxref.com since android xref has old baselines only.Tarra
V
6

I've found a way to get only the Contacts application:

git clone https://android.googlesource.com/platform/packages/apps/Contacts

which is good enough for me for now, but doesn't answer the question of browsing the code on the web.

Vermouth answered 16/1, 2009 at 7:34 Comment(1)
One can indeed get individual packages by pulling their git repositories from a currently active URL. However, this is mostly useful for study - even things that seem like they should be SDK-based ordinary applications typically have dependencies elsewhere in AOSP and so will not build via the SDK, but rather only in the context of a larger build of a more complete AOSP checkout.Abri
O
1

You can browse Android SDK samples from your smartphone using "Code Search": https://market.android.com/details?id=sqwady.codesearch

Onetime answered 18/12, 2011 at 20:11 Comment(0)
V
1

This eclipse plugin allows for inline source viewing and even stepping inside the Android source code:

http://code.google.com/p/adt-addons/

(edit: specifically the "Android Sources" plugin: http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/)

Valeta answered 5/3, 2012 at 17:14 Comment(0)
S
0

gitweb will allow you to browse through the code (and changes) via a browser.

http://git.or.cz/gitwiki/Gitweb

(Don't know if someone has already setup a public gitweb for Android, but it's probably not too hard.)

Slant answered 16/1, 2009 at 7:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.