Download the Android4.2 source code on Ubuntu 12.04
The download process consists of the following steps:
1. Install curl
Run sudo apt-get install curl on the terminal
2. Create ~ /Bin directory and add it to Environment Variables
$ Mkdir ~ /Bin
$ PATH = ~ /Bin: $ PATH
3. Download the repo script and modify the permission to be executable.
$ Curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo> ~ /Bin/repo
$ Chmod a + x ~ /Bin/repo
4. Create a directory for saving the android source code and change it to the maximum permission (this is an operation I added myself, for fear of having insufficient operation permissions in the future), and go to the directory.
$ Mkdir/opt/android_source
$ Sudo chmod-R 777/opt/android_source
$ Cd/opt/android_source
5. initialize the repo and select the branch (version) to be downloaded)
$ Repo init-u https://android.googlesource.com/platform/manifest
$ Repo init-u https://android.googlesource.com/platform/manifest-b android-4.2_r1
Note: In this process, enter your name, email address, and other information. You just need to enter it. I entered a random name, my own 126 mailbox.
6. Start to download the source code.
$ Repo sync
Under normal circumstances, the above is the process of downloading the android4.2 source code, but I encountered the following problems during the download process:
Question 1: "A new repo command (1.18) is available ."
In fact, this problem means that your local repo version is not 1.18, Which is older than this. When this occurs, the following prompt will show you how to operate it, for example:
... A new repo command (1.18) is available.
... You shoshould upgrade soon:
Cp/home/pn/android /. repo/home/pn/bin/repo (you can execute this sentence), and start to find this solution through the Internet ,,,, A lot of time is wasted ..
Question 2: "error: Exited sync due to fetch errors ..."
In this case, IP authentication is required on the Internet.
Http://blog.csdn.net/fantao015/article/details/7625559
The above operation was executed once, including registering a @ gmail.com email, and later I found that I did not use this and all downloaded successfully.
Problem 3: frequent prompts
Error: Failed connect to android.googlesource.com: 443; Connection refused while accessinghttps: // android.googlesource.com/a/platform/frameworks/base/info/refs
Fatal: HTTP request failed
Error: Cannot fetch platform/tools/motodev
Error: Cannot fetch platform/frameworks/base
Error: Cannot fetch platform/prebuilts/sdk
Error: Exited sync due to fetch errors
And other error messages.
Solution: edit the/etc/hosts file.
$ Vim/etc/hosts
Add the following content and save it.
74.125.71.82 www.googlesource.com
74.125.71.82 android.googlesource.com
203.208.46.172 cache.pack.google.com
59.24.3.173cache.pack.google.com
Then enter again
$ Repo sync
This DNS resolution prompt shows the access success rate. If you are interested, you can study it .. Ah, if you find this operation early, it will save me a good time.