Android 源碼下載(國內(nèi)、win,我抄的)

原文地址,我看了很多篇博客,這個是最全面的

一、下載步驟
1.安裝git
2.安裝python
3.下載源碼
二、下載源碼:
1.clone 命令

// 沒有翻墻網(wǎng)絡(luò) 只能clone 清華鏡像
git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git

2.操作截圖:


image.png

3.切換要下載的Android源碼分支
比如我想下載到android-10.0.0_r40的源碼,可以使用如下命令:

git switch -c android-10.0.0_r40

操作結(jié)果如下:


image.png

4.編寫Python腳本,開始下載android-10.0.0_r40 源碼
4.1. 自動化下載Android 10 腳本參考如下

注意事項:我之前腳本編譯一直失敗原因是:把路徑的"/ "換成了""

import xml.dom.minidom
import os
from subprocess import call

## 注意地址中使用的是 "/" 而不是"\", unbantu 跟Windows 是有區(qū)別的
 
#代碼保存位置,硬盤建議大于100G
rootdir = "E:/AOSP/android_10_0_0_r40"
 
#git 安裝路徑,可以使用 where git 命令查看 
git = "E:/software/git/path/mingw64/bin/git.exe"

# 剛剛切換 android-10.0.0_r40 目錄下的defaul.xml 文件
dom = xml.dom.minidom.parse("E:/AOSP/clone_tsinghua/manifest/default.xml")
root = dom.documentElement

# clone 清華大學(xué)鏡像庫地址 
prefix = git + " clone https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/"
suffix = ".git"
 
if not os.path.exists(rootdir):
    os.mkdir(rootdir)
 
for node in root.getElementsByTagName("project"):
    os.chdir(rootdir)
    d = node.getAttribute("path")
    last = d.rfind("/")
    if last != -1:
        d = rootdir + "/" + d[:last]
        if not os.path.exists(d):
            os.makedirs(d)
        os.chdir(d)
    cmd = prefix + node.getAttribute("name") + suffix
    call(cmd)

4.2.執(zhí)行下載Android 10 的腳本
雙擊downloadAOSP.py或者執(zhí)行 python downloadAOSP.py 既可以開始下載Android 10 源碼,經(jīng)過一段時間漫長等待,就可以查看Android Q的源碼了。
4.3.開始成功下載源碼截圖


image.png

三、源碼下載工具包

鏈接: https://pan.baidu.com/s/1GkGiKROmcfPD7oSL8EYhOw
提取碼: uiv4

源碼下載參考鏈接,

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容