Android source code download method specific explanation

Source: Internet
Author: User

Zhang Xing Zhaoyuan

I'm sure a lot of people who have downloaded the kernel are very familiar with this.
git clone git://android.git.kernel.org/kernel/common.git kernel
But this was once, and now, assuming this is going to work, it would show a demo like the following
Initialized Empty Git repository in/home/star/working/kernel/.git/
ANDROID.GIT.KERNEL.ORG[0:149.20.4.77]: Errno=connection refused
Fatal:unable to connect a socket (Connection refused)
Enter http://android.git.kernel.org/through the browser and find that the site has been redirected to http://source.android.com/source/downloading.html
The download method of the kernel can be found at the end of the page.

Below we introduce the steps of Android source code download.

Working environment:

operating system : Ubuntu 10.04 or Ubuntu10.10

git program : 1.7.0.4 or 1.7.1

Reprint Please specify source: http://blog.csdn.net/pku_android

Method One:
1.1 Initializing the installation environment
References Page http://source.android.com/source/initializing.html
The main thing to do is to install the JDK and install some packages
$ sudo apt-get install Git-core GnuPG Flex Bison gperf build-essential \
Zip Curl Zlib1g-dev Libc6-dev Libncurses5-dev x11proto-core-dev \
Libx11-dev libreadline6-dev libgl1-mesa-dev Tofrodos python-markdown \
Libxml2-utils
Assuming it's installed, don't take this step.

1.2 Regardless of the download kernel and source code, need to do such as the following operations
References Page http://source.android.com/source/downloading.html
$ mkdir ~/bin
$ Path=~/bin: $PATH
$ Curl Https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Create a directory so that the downloaded content is saved
$ mkdir working_directory
$ CD Working_directory

1.3 Kernel Download
$ git clone https://android.googlesource.com/kernel/common.git kernel
The command line at the back of the kernel meaning is saved in this directory, so can be no matter what name, the directory does not need to create their own, the last of this does not write the problem
Suppose you want to download a kernel with a different version number
$ git clone https://android.googlesource.com/kernel/goldfish.git
$ git clone https://android.googlesource.com/kernel/msm.git
$ git clone https://android.googlesource.com/kernel/omap.git
$ git clone https://android.googlesource.com/kernel/samsung.git
$ git clone https://android.googlesource.com/kernel/tegra.git
During the download process, there will be information such as the following, depending on the speed of the network.
Initialized Empty Git repository in/home/star/kernel/kernel/.git/
Remote:counting objects:40, done
Remote:counting objects:2073952, done
Remote:finding sources:100% (208/208)
Remote:getting sizes:100% (88/88)
Remote:compressing objects:100% (2/2)
Remote:total 2073863 (Delta 1735363), reused 2073862 (Delta 1735363)
Receiving objects:100% (2073863/2073863), 427.93 MiB | 318 kib/s, done.
Resolving deltas:100% (1735382/1735382), done.
During the course of my download, there were issues such as the following
Error:rpc failed; result=56, HTTP code = 2002 MiB | kib/s
And now I don't know what's causing it.
Did you do all the things you said in 1.1? I found that some of the installation packages have not been installed and installed.
Or maybe it's a network problem, run it over and over again, and you'll find that it's not the same place that's going to happen.
Or, download it with someone else's computer (although the method I found, but not my first successful download, I met the RPC failed, then let the students try, success, I also tried, after the need to install the installation package is also successful)

1.4 Replace the kernel version number
Because in 1.3 I wrote the kernel, which is able to see a kernel folder that appears under the current folder
$ CD kernel/
$ ls
Found no matter what the content
View current kernel version number, master, I don't know what it means.
$ git Branch
* Master
View all available kernel version numbers
$ git branch-a
* Master
Remotes/origin/head-Origin/master
remotes/origin/android-2.6.39
remotes/origin/android-3.0
Remotes/origin/master
To see that there are only a few version numbers available now, just 2.6.39 and 3.0, for example I want to download 2.6.39
$ git checkout-b android-2.6.39 origin/android-2.6.39
Switched to a new branch ' android-2.6.39 '
The android-2.6.39 of the command refers to the name of the branch, in fact can be arbitrarily taken, the key is origin/android-2.6.39, to the corresponding git branch-a command to display the remotes behind the content
When you are finished, query the current branch
$ git Branch
* android-2.6.39
Master
$ ls
Arch documentation init Lib README sound
Block drivers IPC maintainers reporting-bugs Tools
COPYING firmware kbuild Makefile samples usr
CREDITS fs Kconfig mm Scripts Virt
Crypto include kernel net security
You'll see a lot of directories popping up, that's the kernel.
Because of the wrong operation
For example $ git checkout-b android-2.6.39 origin/android-2.6.39, just enter $ git checkout-b android-2.6.39, at which point you get an empty branch
$ git branch-a
* android-2.6.39
Master
Remotes/origin/head-Origin/master
remotes/origin/android-2.6.39
remotes/origin/android-3.0
Remotes/origin/master
Assuming run again
$ git checkout-b android-2.6.39 origin/android-2.6.39
Fatal:git Checkout:branch android-2.6.39 already exists
One way is to change the android-2.6.39 after-B to a different name, but this problematic branch android-2.6.39 will still exist.
View Git branch--help, find the branch Delete command
$ git branch-d android-2.6.39
Error:cannot Delete the branch ' android-2.6.39 ' which you is currently on.
Need to switch branches, if there is also android-3.0, of course, can also switch to master or other existing branches, $ git branch-a view Branch
$ git checkout android-3.0
Checking out files:100% (37131/37131), done.
Switched to branch ' android-3.0 '
$ git branch-d android-2.6.39
Deleted Branch android-2.6.39 (was fe8bf45).

Reprint Please specify source: http://blog.csdn.net/pku_android

Method Two
2.1 References 1.1 and 1.2

2.2 Similar to the process of downloading the Android source code, first run the following command, for example
$ repo Init-u https://android.googlesource.com/platform/manifest
In this step you need to use Gmail's mailbox
In the process of downloading the Android source code, and will not download kernel, then how to download the source code, and download kernel it?
References Page Http://elinux.org/Android_Kernel_Download
A kernel git tree is not referenced by the default Android manifest file
Since there is no reference, then add it
Change. Repo/manifest.xml (the current folder is the established working_directory in 1.2)
$ vim. Repo/manifest.xml
Add this statement
<project path= "Kernel/common" name= "Kernel/common" revision= "android-2.6.39"/>
Location I think with the other project options you can.
Version 1.4, may only be able to download 2.6.39 and 3.0

2.3 Download source code and kernel
$ repo Sync
A long wait
Let's say I just want to download the kernel.
Very easy, change the file mentioned in 2.2. Repo/manifest.xml, delete all project tags, and then join?
<project path= "Kernel/common" name= "Kernel/common" revision= "android-2.6.39"/>

Reprint Please specify source: http://blog.csdn.net/pku_android


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.