1. 程式人生 > >Android原始碼下載教程(repo)

Android原始碼下載教程(repo)

環境

  • ubuntu系統

原始碼下載

  • 首先下載repo工具
 mkdir ~/bin 
 PATH=~/bin:$PATH 
 curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 
 ## 如果上述 URL 不可訪問,可以用下面的:
 ## curl https://storage-googleapis.lug.ustc.edu.cn/git-repo-downloads/repo > ~/bin/repo 
 chmod a+x ~/bin/repo

  • 然後建立一個工作目錄
mkdir android
cd android
  • 初始化倉庫命令
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest 
## 如果提示無法連線到 gerrit.googlesource.com,可以編輯 ~/bin/repo,把 REPO_URL 一行替換成下面的: 
## REPO_URL = 'https://gerrit-googlesource.proxy.ustclug.org/git-repo'

  • 如果需要某個特定的android版本

例如我想下載 android-8.1.0_r8

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-8.1.0_r8
  • 同步原始碼樹
repo sync

編譯相關

cd android //切到android目錄下 
source build/envsetup.sh lunch //選擇編譯版本型別 
23 //針對不同型別選擇序號,我這裡選擇23 user版 
make -j32 //全編,-j加快編譯速度 
mmm packages/apps/Helloword/ //單模組編譯 
切換到要編譯的目錄下 mm -B 
make clean //清除out目錄檔案