【Android 系统】--- 下载 Android源码超详细

在这里插入图片描述

  • 一个好的文章能够帮助开发者完成更便捷、更快速的开发。
  • 书山有路勤为径,学海无涯苦作舟。我是秋知叶i、期望每一个阅读了我的文章的开发者都能够有所成长。

开发环境

开发环境:Ubuntu16.04

一、下载工具

AOSP:Android Open-Source Project"的缩写。中文意为"Android 开放源代码项目。

需要的工具 repo 搭建repo教程

二、创建git账户

  • 账户名
git config --global user.name "Your Name"
  • 账户邮箱
git config --global user.email "email@example.com"

三、特别说明

  • 可能会出现报错

git error:error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.

  • 解决方法:
git config --global http.postBuffer 2000000000

四、下载最新 AOSP 源码

1、初始化仓库

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest

2、同步源码

repo sync

5:下载特定版本 AOSP 源码

1、初始化仓库

  • 需要同步特定的 Android源码版本 比如android-6.0.1_r22

  • 在后面加 -b 参数 再加上自己想要的版本

  • Android版本列表

  • 加上–depth=1 --platform=auto参数可以大幅度增加下载速度

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-6.0.1_r22 --depth=1 --platform=auto

2、出现错误

repo /usr/bin/env: “python”: 没有那个文件或目录

在这里我直接选择 N

icedustpan@Vbox:~/aosp/android-6.0.1_r22$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-6.0.1_r22
Downloading Repo source from https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
remote: Enumerating objects: 6734, done.
remote: Counting objects: 100% (6734/6734), done.
remote: Compressing objects: 100% (3496/3496), done.
remote: Total 6734 (delta 4333), reused 5241 (delta 3165)
接收对象中: 100% (6734/6734), 2.93 MiB | 4.27 MiB/s, 完成.
处理 delta 中: 100% (4333/4333), 完成.
repo: Updating release signing keys to keyset ver 2.3
Downloading manifest from https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
remote: Enumerating objects: 4583, done.
remote: Counting objects: 100% (4583/4583), done.
remote: Compressing objects: 100% (3890/3890), done.
remote: Total 89936 (delta 2164), reused 93 (delta 21) 
接收对象中: 100% (89936/89936), 21.15 MiB | 5.96 MiB/s, 完成.
处理 delta 中: 100% (33616/33616), 完成.

Your identity is: icedustpan <icedustpan@163.com>
If you want to change this, please re-run 'repo init' with --config-name

Testing colorized output (for 'repo diff', 'repo status'):
  black    red      green    yellow   blue     magenta   cyan     white 
  bold     dim      ul       reverse 
Enable color display in this user account (y/N)? N

repo has been initialized in /home/icedustpan/aosp/android-6.0.1_r22

3、同步源码

repo init时加上–depth=1 参数,下载的代码每个git仓只包含一个commit信息,repo sync时加上-c参数,只下载当前分支相关的代码,二者结合起来,可以大大缩小整个工程的代码,

repo sync -c -j4

五、脚本

repo sync 断点自动下载脚本

#!/bin/bash

repo sync -c -j4

while [ $? -ne 0 ]
do
echo "----------sync failed----------"
sleep 10
repo sync -c -j4
done

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 11
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秋知叶i

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值