27

I try to search for it but I just cant. I am running Windows 7 on Lenovo G460 laptop. I tried to install Ubuntu on it but I cannot use Wireless to connect to the internet for some reason.

Is there anyway for me to get a look at Android source code or at least just the Calendar part of it?

Volo
  • 28,673
  • 12
  • 97
  • 125
RobGThai
  • 5,937
  • 8
  • 41
  • 59

6 Answers6

31

You can browse the android source code using their repository browser. If you want to check out a specific project (i.e. download the source), you will need to get the version control system Git. When you have Git running, you can either clone a complete repository using git clone https://android.googlesource.com/projectname.git or just get the HEAD (the most current version of all files, useful if you only want to browse through the source) by doing git clone --depth 1 https://android.googlesource.com/projectname.git.

The project name is the top folder you select on the repository browser, for example platform/packages/apps/Calendar for the Calendar app. Then the full command is git clone https://android.googlesource.com/platform/packages/apps/Calendar.

poke
  • 369,085
  • 72
  • 557
  • 602
  • 1
    I encountered a problem when accessing the git:// URL - "android.git.kernel.org[0: 130.239.17.13]: errno=Connection timed out". It looks like some ports were blocked by a firewall. What worked for me was using the http:// URL instead – Moshe Kravchik Aug 29 '11 at 13:20
  • Its taking too long time on my pc with my flaky internet, it goes to reset every time. Is it possible to download just the release branch of the codebase, which can finish in half a day? – Gopinath Nov 29 '12 at 10:11
  • 2
    @Gopinath See what I wrote about getting just the HEAD, i.e. get a shallow clone using the `--depth 1` parameter. – poke Nov 29 '12 at 11:49
16

The GitWeb and Google Code Search repositories for Android have been retired since this question was originally answered. Fortunately, the SDK Manager finally allows you to download the source code for Android 4.0 and later along with all of the APIs and tools.


If you need access to pre-Ice Cream Sandwich (4.0) Android source code and don't want to use Google's non-Windows download instructions, you can search GrepCode for what you need online. (Look for "android" and the name of the class or method you want, and then pick the version of the code you want.)

GrepCode works, but I have seen it crash IE a bunch of times. An alternative would be to download the Android Sources plugin for Eclipse, which gives you all of the source code for versions of Android up to 4.0.1.


Once you have the source code, you can attach the source directory you are using to your .jar in Eclipse, as follows:

Right-click the project > Properties > Java Build Path > Libraries tab > select the + beside the .jar you want to attach source code to > click on Source Attachment to edit the path to where the source files reside.

ethry
  • 731
  • 6
  • 17
hotshot309
  • 1,718
  • 1
  • 18
  • 20
  • Update: I was just using GrepCode today and didn't have an issue in IE 9 at any point The problems I had in the past were probably version dependent. – hotshot309 Nov 15 '13 at 22:40
2

Steps:

  1. Download Cygwin from http://cygwin.com/install.html.
  2. Install cygwin with almost all defaults. During cygwin setup, select modules curl and python (search for them) and mark them to be installed.
  3. Start cygwin.exe and go to your preferred directory (mine is D:/Android/sources/4.0/try2). Example: $: cd /cygdrive/d/Android/sources/4.0/try2

  4. Run the below instructions one by one:

    i) mkdir bin

    ii) PATH=/cygdrive/d/Android/sources/4.0/try2/bin:$PATH

    iii) curl https://storage.googleapis.com/git-repo-downloads/repo > /cygdrive/d/Android/sources/4.0/try2/bin/repo

    iv) mkdir source

    v) cd source

    vi)
    Master branch:
    repo init -u https://android.googlesource.com/platform/manifest

    4.0.1 branch for example:
    repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1

    vii) Give credentials if needed

    viii) repo sync

Source: click here

milosmns
  • 3,595
  • 4
  • 36
  • 48
Mohsen Zahraee
  • 3,309
  • 5
  • 31
  • 45
2

Thanks a lot, a quick guide on helping the download in windows, check this

http://honey200.wordpress.com/2011/11/17/download-android-source-code-in-windows/

  • 4
    I suggest you add a summary of the link in your answer. Links have a habbit of breaking over time making it difficult to get an answer. – M Afifi Nov 06 '12 at 16:31
1

1) Install Git: http://git-scm.com/

2) Open Git Bash from Start Menu > Git > Git Bash

3) In Git Bash window, change current directory to your favorite directory (For example D:\android_src) by following command: cd /d/androidsrc/

4) In Windows Explorer, create an empty file D:\android_src\download.sh and open it by notepad

5) Open the following link and copy the code & paste it into D:\android_src\download.sh, then save and close the notepad:

http://pastebin.com/DfqBFKnK

6) Execute download shell script in Git Bash window by following command: ./download.sh

See also: https://android.googlesource.com/

Amir Saniyan
  • 13,014
  • 20
  • 92
  • 137
0

Install cygwin, and install the cygwin verion of git, then follow the normal instructions for installing repo.

You'll want to have git around anyway - it's become the standard vcsfor modern dev work. Some stuff is in svn still, but that's dying out.

James Moore
  • 8,636
  • 5
  • 71
  • 90