日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Windows系统下载Android源码

發布時間:2024/8/1 Android 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Windows系统下载Android源码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

        • 1. 前言
        • 2. 準備工作
        • 3. 下載源碼
        • 4. 小結

1. 前言

下載Android源碼,官方的網址:https://source.android.google.cn/setup/downloading

一般是提供給Linux系統環境下使用repo獲取源碼,那么Windows環境下的同學們下載源碼的姿勢是怎樣的呢?

下面的內容將簡單介紹一下Windo下載Android源碼的過程。

2. 準備工作

首先,我們知道repo是為了方便管理Android多個git庫而開發的Python腳本,其次,有條件的話,需自備梯子科學上網,當然沒有也有對應的方法處理。最后,建議留有100GB或以上的硬盤容量,因為Android源代碼占用比較大。

綜合上述內容,準備環境內容有:

  • 安裝和配置好Git環境
  • 安裝和配置好Python環境
  • 條件允許的話,自備梯子
  • 留有100GB或以上的硬盤容量

3. 下載源碼

1. 下載倉庫的manifest文件

git clone https://android.googlesource.com/platform/manifest.git // 不能科學上網就選用國內的清華數據源 git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git

這時會在倉庫目錄下會生成 manifest文件夾,里面除了 git 的配置外還有default.xml 文件。default.xml定義Android工程的多個git庫列表,大致結構如下:

<?xml version="1.0" encoding="UTF-8"?> <manifest><remote name="aosp"fetch=".."review="https://android-review.googlesource.com/" /><default revision="master"remote="aosp"sync-j="4" /><project path="art" name="platform/art" groups="pdk" /><project path="frameworks/base" name="platform/frameworks/base" groups="pdk-cw-fs,pdk-fs" /><!--每個project標簽有path和name屬性, --> </manifest>

default.xml中的path是Android工程的路徑結構,而name是git下載的具體路徑值。

如果需要切換下載源碼的分支,進入到manifest里執行git分支切換操作即可。筆者一般下載默認的master分支就好了,其為最新的穩定釋放版本。

2. 新建一個Python文件,復制下面代碼到文件中,修改工程工程路徑后執行此腳本,即可開始下載代碼了

import xml.dom.minidom import os from subprocess import call# 1. 筆者的源碼保存根路徑 rootdir = "E:/AOSP"# 2. 筆者的 git 安裝路徑 git = "D:/Program Files/Git/bin/git.exe"# 3. 筆者的manifest文件夾中default.xml 的文件路徑 dom = xml.dom.minidom.parse("E:/AOSP/manifest/default.xml") root = dom.documentElement# 4. 沒有梯子可以使用清華源下載 # prefix = git + " clone https://android.googlesource.com/" prefix = git + " clone https://aosp.tuna.tsinghua.edu.cn/" 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): # 根據path屬性下的值,創建當前工程的一系列上級目錄os.makedirs(d) os.chdir(d) # 根據prefi的值加上name屬性值拼接對應的git命令下載代碼 cmd = prefix + node.getAttribute("name") + suffix call(cmd)

如果想單獨下載某個模塊,一般的格式為git clone [數據源][project-name].git,這里以Launcher3為例,其project標簽<project path="packages/apps/Launcher3" name="platform/packages/apps/Launcher3"/>,此時name屬性值為platform/packages/apps/Launcher3,拼接數據源得到最終的下載地址:git clone https://aosp.tuna.tsinghua.edu.cn/platform/packages/apps/Launcher3.git

4. 小結

下載Android源代碼是很有必要的,閱讀源代碼可以讓我們對Android有更深的理解。所以我們無論使用哪個操作系統,都應該把代碼下載到本地,方便學習。

總結

以上是生活随笔為你收集整理的Windows系统下载Android源码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。