博文參考網址:https://www.jianshu.com/p/7eaaa99c2cb9
參考資料:
- 自己動手編譯Android源碼(超詳細)(https://www.jianshu.com/p/367f0886e62b)
- AOSP項目環境搭建 http://blog.csdn.net/fengshh2301/article/details/54016445
- AOSP 安卓源碼-ubuntu開發環境搭建 https://www.cnblogs.com/zhen-android/p/7764124.html
- 使用本地AOSP鏡像快速擷取Android代碼 http://blog.csdn.net/sy373466062/article/details/55101705
中科大源
https://lug.ustc.edu.cn/wiki/mirrors/help/aosp#初始同步方法2
可線上檢視中科大鏡像内容:
https://mirrors.ustc.edu.cn/aosp/
export REPO_URL='https://gerrit-googlesource.proxy.ustclug.org/git-repo'
或者
export REPO_URL='https://mirrors.ustc.edu.cn/aosp/git-repo.git/'
清華大學源:
參考 Google 教程 https://source.android.com/source/downloading.html, 将 https://android.googlesource.com/ 全部使用 https://aosp.tuna.tsinghua.edu.cn/ 代替即可。
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
下載下傳repo工具
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
mkdir ~/bin/repo
mv repo ~/bin/repo
chmod +x ~/bin/repo
離線庫
wget https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下載下傳初始化包
tar xf aosp-latest.tar
cd AOSP # 解壓得到的 AOSP 工程目錄
#已有倉庫如何改用科大源,請修改 .repo/manifests.git/config,将
# url = https://android.googlesource.com/platform/manifest
# 修改成
# url = git://mirrors.ustc.edu.cn/aosp/platform/manifest
# 或 https://mirrors.ustc.edu.cn/aosp/platform/manifest
# 這時 ls 的話什麼也看不到,因為隻有一個隐藏的 .repo 目錄
repo sync # 正常同步一遍即可得到完整目錄
# 或 repo sync -l 僅checkout代碼
Android 模拟器編譯
下載下傳模拟器代碼分支
# repo init -u https://android.googlesource.com/platform/manifest -b emu-2.5-release
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b emu-2.5-release
repo init -u https://mirrors.ustc.edu.cn/aosp/platform/manifest -b emu-2.6-release
編譯
cd external/qemu/android/
./rebuild.sh --no-tests
其它見:http://blog.csdn.net/tq08g2z/article/details/77932200
中科大源失敗:
Fetching projects: 2% (1/37) Fetching project platform/prebuilts/cmake/windows-x86
Fetching projects: 5% (2/37) Fetching project platform/prebuilts/android-emulator-build/curl
error: Cannot fetch platform/prebuilts/cmake/windows-x86
Fetching project platform/external/angle
fatal: remote error: access denied or repository not exported: /aosp/platform/external/angle
error: Cannot fetch platform/prebuilts/android-emulator-build/curl
error: Cannot fetch platform/prebuilts/android-emulator-build/protobuf
error: Cannot fetch platform/prebuilts/ninja/windows-x86
fatal: remote error: access denied or repository not exported: /aosp/platform/external/angle
error: Cannot fetch platform/external/angle
清華大學源:
Fetching project platform/prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8
Fetching project platform/prebuilts/ninja/windows-x86
Fetching project platform/external/tinyobjloader
Fetching project platform/prebuilts/android-emulator-build/protobuf
error: no such remote ref c179f1c3d3fcddfe22e1692756a3912dd42996f6
error: Cannot fetch platform/prebuilts/android-emulator-build/protobuf
Fetching project platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8
Fetching projects: 2% (1/39) error: no such remote ref b88e85c90e260cfed1d5130499b8dfd7bb9dc02a
error: Cannot fetch platform/prebuilts/ninja/windows-x86
Fetching projects: 7% (3/39)
error: Exited sync due to fetch errors
踩坑
-
踩坑1:
https://www.jianshu.com/p/3b0a9904daca
-
踩坑2:
Not replacing locally modified commit-msg hook
windows下解壓的tar檔案,釋放時有些link沒有正确的釋放。
在ubuntu下重新解壓即可
-
坑3:
在 repo init -u https://mirrors.ustc.edu.cn/aosp/platform/manifest -b emu-2.6-release 後,repo sync後在clone部分manifest中clone-depth為1的結點時出錯。
日志見:https://gist.github.com/k1988/9558b4591f6607be1dd578d65b9e92d8
臨時解決方案:
如果出錯,就将.repo/manifest.xml中
<project clone-depth="1"
改為
<project
正确解決方案:
後面聯系清華的管理者,問題是清華的鏡像 @huiyiqun 伺服器上 git 需要更新到 2.5 以上,他打開 uploadpack.allowReachableSHA1InWant 這個選項後即可。
-
坑4:
/aosp/platform/external/angle 下載下傳失敗。
huiyiqun17:29:59 default.xml - mirror/manifest - Git at Google
https://android.googlesource.com/mirror/manifest/+/master/default.xml via telegram
huiyiqun17:30:17 我們是依據這個檔案鏡像的 via telegram
huiyiqun17:30:27 這個檔案裡沒有…
清華大學沒有同步非master的git。