1. 程式人生 > >Android原始碼編譯(3)---下載原始碼

Android原始碼編譯(3)---下載原始碼

The Android source tree is located in a Git repository hosted by Google. The Git repository includes metadata for the Android source, including those related to changes to the source and the date they were made. This document describes how to download the source tree for a specific Android code-line.

Installing Repo

Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see the Developing section.

To install Repo:

  1. Make sure you have a bin/ directory in your home directory and that it is included in your path:

    $ mkdir ~/bin
    $ PATH=~/bin:$PATH
    
  2. Download the Repo tool and ensure that it is executable:

    $ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    $ chmod a+x ~/bin/repo

For version 1.17, the SHA-1 checksum for repo is ddd79b6d5a7807e911b524cb223bc3544b661c28

For version 1.19, the SHA-1 checksum for repo is 92cbad8c880f697b58ed83e348d06619f8098e6c

For version 1.20, the SHA-1 checksum for repo is e197cb48ff4ddda4d11f23940d316e323b29671c

For version 1.21, the SHA-1 checksum for repo is b8bd1804f432ecf1bab730949c82b93b0fc5fede

For version 1.22, the SHA-1 checksum for repo is da0514e484f74648a890c0467d61ca415379f791

Initializing a Repo client

After installing Repo, set up your client to access the Android source repository:

  1. Create an empty directory to hold your working files. If you're using MacOS, this has to be on a case-sensitive filesystem. Give it any name you like:

    $ mkdir WORKING_DIRECTORY
    $ cd WORKING_DIRECTORY
  2. Configure git with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.

    $ git config --global user.name "Your Name"
    $ git config --global user.email "[email protected]"
  3. Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.

    $ repo init -u https://android.googlesource.com/platform/manifest

    To check out a branch other than "master", specify it with -b. For a list of branches, see Source Code Tags and Builds.

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

A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.

Downloading the Android Source Tree

To pull down the Android source tree to your working directory from the repositories as specified in the default manifest, run

$ repo sync

The Android source files will be located in your working directory under their project names. The initial sync operation will take an hour or more to complete. For more about repo sync and other Repo commands, see theDeveloping section.

Using Authentication

By default, access to the Android source code is anonymous. To protect the servers against excessive usage, each IP address is associated with a quota.

When sharing an IP address with other users (e.g. when accessing the source repositories from beyond a NAT firewall), the quotas can trigger even for regular usage patterns (e.g. if many users sync new clients from the same IP address within a short period).

In that case, it is possible to use authenticated access, which then uses a separate quota for each user, regardless of the IP address.

The first step is to create a password with the password generator and follow the instructions on the password generator page.

The second step is to force authenticated access, by using the following manifest URI:https://android.googlesource.com/a/platform/manifest. Notice how the /a/ directory prefix triggers mandatory authentication. You can convert an existing client to use mandatory authentication with the following command:

$ repo init -u https://android.googlesource.com/a/platform/manifest

Troubleshooting network issues

When downloading from behind a proxy (which is common in some corporate environments), it might be necessary to explicitly specify the proxy that is then used by repo:

$ export HTTP_PROXY=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port>
$ export HTTPS_PROXY=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port>

More rarely, Linux clients experience connectivity issues, getting stuck in the middle of downloads (typically during "Receiving objects"). It has been reported that tweaking the settings of the TCP/IP stack and using non-parallel commands can improve the situation. You need root access to modify the TCP setting:

$ sudo sysctl -w net.ipv4.tcp_window_scaling=0
$ repo sync -j1

Using a local mirror

When using several clients, especially in situations where bandwidth is scarce, it is better to create a local mirror of the entire server content, and to sync clients from that mirror (which requires no network access). The download for a full mirror is smaller than the download of two clients, while containing more information.

These instructions assume that the mirror is created in /usr/local/aosp/mirror. The first step is to create and sync the mirror itself. Notice the --mirror flag, which can be specified only when creating a new client:

$ mkdir -p /usr/local/aosp/mirror
$ cd /usr/local/aosp/mirror
$ repo init -u https://android.googlesource.com/mirror/manifest --mirror
$ repo sync

Once the mirror is synced, new clients can be created from it. Note that it's important to specify an absolute path:

$ mkdir -p /usr/local/aosp/master
$ cd /usr/local/aosp/master
$ repo init -u /usr/local/aosp/mirror/platform/manifest.git
$ repo sync

Finally, to sync a client against the server, the mirror needs to be synced against the server, then the client against the mirror:

$ cd /usr/local/aosp/mirror
$ repo sync
$ cd /usr/local/aosp/master
$ repo sync

It's possible to store the mirror on a LAN server and to access it over NFS, SSH or Git. It's also possible to store it on a removable drive and to pass that drive around between users or between machines.

Verifying Git Tags

Load the following public key into your GnuPG key database. The key is used to sign annotated tags that represent releases.

$ gpg --import

Copy and paste the key(s) below, then enter EOF (Ctrl-D) to end the input and process the keys.

-----BEGIN PGP PUBLIC KEY BLOCK-----Version:GnuPG v1.4.2.2(GNU/Linux)

mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw78tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv
aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k
cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX
gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI
2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl
QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up
hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk
C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX
LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M
pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0lEXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM==Wi5D-----END PGP PUBLIC KEY BLOCK-----

After importing the keys, you can verify any tag with

$ git tag -v TAG_NAME

If you haven't set up ccache yet, now would be a good time to do it.

相關推薦

Android原始碼編譯(3)---下載原始碼

The Android source tree is located in a Git repository hosted by Google. The Git repository includes metadata for the Android source, including those rel

android4.4系統原始碼編譯(二)_原始碼下載

       上節說到環境搭建成功,現在開啟下載android系統原始碼的旅程吧! 1. 參考連結    Android原始碼下載和編譯: http://www.cnblogs.com/qianxud

ANDROID編譯工具APKTOOL原始碼除錯過程

APKTOOL是目前反編譯ANDROID apk的主要工具,可以反編譯出APK裡的資原始檔和smali程式碼,而有些APK開發者為了防止自己的程式碼被反編譯,針對APKTOOL工具加固程式碼,使得APKTOOL無法執行正常,比如這篇文章介紹的Android應用資

關於android studio編譯下載更新檔案錯誤解決方法總結

最近計劃用android studio設計一個android程式,開啟後確發現編譯總是報錯,上網找了很多辦法,其中說的最多的是關於下載更新gradle的,這裡稍微提一下: android studio更新gradle常常需要翻牆,可以直接到http://services.gradle.org

Monkey原始碼分析3—Monkey原始碼的整體設計結構

Monkey原始碼地址,點選檢視 Monkey自動化測試的本質就是隨機生成一個事件,然後向Android設備註入一個事件。通俗的來說就是,monkey隨機生成一個點選螢幕事件,然後選取Android螢幕的一個座標,對此座標進行點選操作。來實現自動化測試的。當然產生的事件不

Ubuntu 14.04編譯Android 2.3.7原始碼記錄

編譯環境 下載原始碼 下載原始碼 Android 2.3.7r1 原始碼,原本按照谷歌官方的指導,需要下載repo同步AOSP,但是遇到太多問題,並且.repo 檔案相當大,下載耗時太久,而且很容易出現問題,而且所以直接下載別人打包好的7z

Android 7.1.1系統原始碼下載編譯、刷機-Nexus 6實戰

基本概念 AOSP : 就是Android Open Source Project也就是谷歌開放原始碼專案。 通過Google官方下載的原始碼也就是AOSP的程式碼,是不包含Google開發的全家桶的應用。 ps: 這個作為一個Android程式設計師肯定要知道的一個專業詞

Android 在ubuntu上下載編譯系統原始碼

網上也有很多這樣的教程,這裡只是把它記錄下來,方便日後檢視。 下載原始碼 分為以下幾個步驟: 1、配置安裝下載環境   配置 JDK環境   安裝curl、git-core軟體  sudo apt-get install curl  sudo apt-get inst

centos7下docker1.10.3 rpm 原始碼編譯小記

下載rpm原始碼包 比如從https://cbs.centos.org/koji/buildinfo?buildID=16801上下載原始碼釋出包:docker-1.10.3-59.el7.centos.src.rpm 提取原始碼 通過如下命令將打了所有的patch後的原始碼

[環境配置]Ubuntu 16.04 原始碼編譯安裝OpenCV-3.2.0+OpenCV_contrib-3.2.0及產生的問題

1.OpenCV-3.2.0+OpenCV_contrib-3.2.0編譯安裝過程 1)下載官方要求的依賴包 GCC 4.4.x or later CMake 2.6 or higher Git GTK+2.x or higher, including headers (libgtk2.

LeakCanary Android 記憶體洩漏分析利器 原始碼編譯配置mk檔案

LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := \ $(call all-java-files-under, src) LOCAL_SRC_

Android 原始碼編譯make的錯誤處理

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

Android原始碼編譯之Nexus5真機編譯

轉載:https://blog.csdn.net/liu1075538266/article/details/51272398 1.   前言 在Android安全的研究工作中,我們時常要對Android進行改進並對其進行原始碼編譯,由於目前幾乎所有的手機廠商均

python 自動操作 android原始碼編譯某一個apk

import os def getCmdEexcuteResult(cmd): tmp = os.popen(cmd).readlines() return tmp def doWork(): cmdList=['adb root', '

遊戲製作之路-憤怒的小鳥-3原始碼下載地址)

我們先來分析一下整體的程式碼框架,這是我的指令碼目錄 首先我們給主角也就是小鳥新增剛體,碰撞器元件,最重要的是unity中的彈簧元件SpringJoint,作用是把兩個物體像彈簧一樣來連線到一起,受力學的作用, 最後我們建立指令碼bird.cs: 滑鼠按下來調整鳥的位置,角度,取消運動力學

Android ADB 命令及原始碼編譯命令筆記

ADB 常用命令 adb root:獲取root 許可權 adb remount:重新掛載 adb shell :進入terminal adb devices -s serialnumber :檢視指定裝置狀態 adb devices 獲取裝置列表及裝置狀態 adb kill-ser

GeoMesa編譯與二次開發專欄(3) — GeoMesa原始碼編譯

前言 1、參考:GeoMesa官方英文文件:https://www.geomesa.org/documentation/developer/introduction.html 2、本篇介紹瞭如何編譯GeoMesa原始碼,即官方文件中所謂的從原始碼構建GeoMesa,以及對GeoM

Android原始碼編譯jar包BUILD_JAVA_LIBRARY 與BUILD_STATIC_JAVA_LIBRARY的區別

 Android原始碼編譯jar包BUILD_JAVA_LIBRARY 與BUILD_STATIC_JAVA_LIBRARY的區別(一) http://www.cnblogs.com/zhhd/p/5392913.html 上面是參考文章的連結,下面是我的編譯指令碼(An

Android進階3:Activity原始碼分析(2) —— Activity啟動和銷燬流程(8.0)

上篇文章講述了app從啟動建立Activity呼叫onCreate,onStart, onResume方法,這篇文章講述一下Activity啟動的另一個切入點:startActivity方法,啟動Activity。 通過上一篇文章,我們總結一下: 1:A

android原始碼閱讀三》android原始碼編譯匯入android studio

1、安裝 Java 輸入命令 java,報以下錯誤: Command 'java' not found, but can be installed with: sudo apt insta