日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

AOSP源碼下載示例代碼_Android

作者:Amosstan ? 更新時間: 2022-10-10 編程語言

一、說明

由于一些原因,利用谷歌的資源下載Android源碼速度很慢,我們可以用清華源里面的資源進行下載。
清華源AOSP配置下載地址詳解:Android 鏡像使用幫助

二、源碼下載示例

由于清華源中給出很清晰的配置下載方法,這兒只做幾條總結:

1. 谷歌鏡象不可用,采用清華源鏡象

https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

2. 配置repo

mkdir ~/bin
PATH=~/bin:$PATH
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo

注意:repo最好加到系統的環境變量中。

3. repo更新

repo的運行過程中會嘗試訪問官方的git源更新自己,如果想使用tuna的鏡像源進行更新,可以將如下內容復制到你的~/.bashrc里

export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

并重啟終端模擬器。

4. 下載初始化包

wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar

5. 解壓資源包

tar xf aosp-latest.tar

6. 更新指定版本

比如指定下載android-6.0.1_r62,執行以下命令:

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-6.0.1_r62
repo sync

如果遇到"SyntaxError: invalid syntax"等錯誤,如下所示:

? File "/home/jerry/workspace/aosp/.repo/repo/main.py", line 79
? ? file=sys.stderr)
? ? ? ? ^
SyntaxError: invalid syntax

應該是python語法導致的,解決方法如下:

python3 ~/bin/repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-6.0.1_r62
python3 ~/bin/repo sync

7. 快捷腳本

由于網絡及限制網絡并發等原因,repo sync常常更新失敗,可以用腳本來更新,腳本示例:

	repo sync -j4
	while [ $? = 1 ]; do
	        echo "==== sync failed, re-sync again ===="
	        sleep 3
	        repo sync -j4
	done

三、注意

1. 遇到同步失敗的問題

比如OMA-DM這個app同步失敗,我們可以修改AOSP目錄下的.repo/manifests/default.xml來屏蔽掉這個應用的同步,如下圖:

2. 遇到python語法問題

參照如下語法根據實際情況執行repo命令,注意repo要寫上絕對路徑,否則會報錯。

python3 ~/bin/repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-6.0.1_r62
python3 ~/bin/repo sync

原文鏈接:https://blog.csdn.net/Amosstan/article/details/113335459

欄目分類
最近更新