Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

在 Ubuntu 下載 Google Android 4.4 源碼的完整流程

Windows 使用者可以先裝 Cygwin,再依同樣的步驟在 Cygwin 環境中拉取 Android 源碼。以下以 Ubuntu 為示範環境。

一、先備工具

sudo apt-get install curl
sudo apt-get install git-core

二、取得 Repo 工具

先建立安裝目錄並寫進 PATH:

mkdir ~/bin
PATH=~/bin:$PATH

接著下載 repo 腳本:

curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

這個官方網址有時會抓不下來。若遇到失敗,可改用社群提供的鏡像來源:

curl "https://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo

下載完別忘了給它執行權限:

chmod a+x ~/bin/repo

三、建立工作目錄

mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY

四、初始化 manifest

想抓最新版本:

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

想抓特定版本分支,加上 -b 參數,例如當時最新的 4.4 分支:

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

過程中會要求輸入使用者名稱與 email,填自己的即可。

五、同步全部源碼

repo sync

這一步最常出問題,典型錯誤是:

fatal: '../platform/abi/cpp.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
error: Cannot fetch platform/abi/cpp

解法是進入工作目錄,開啟隱藏的 .repo 目錄,編輯 manifest.xml,把 fetch 屬性改成:

fetch="git://Android.git.linaro.org"

另外要有心理準備:repo sync 很少一次就成功,中途超時或斷線都很正常,反覆再執行即可,先前的進度會被快取保留。

Copyright © Linux教程網 All Rights Reserved