打造自己的Android源码学习环境之四:下载Android源代码

下载android代码的全部指导来自:http://source.android.com/source/index.html。
如果你访问不了这个网址,可以看看这个链接。

注意,需要同时在主机系统(Host OS)和虚拟系统(Guest OS)中配置hosts。

0. 安装所需软件

0.1 安装JDK

参考: http://source.android.com/source/initializing.html

$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk

0.2 安装必要的软件包

参考: http://source.android.com/source/initializing.html

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \libgl1-mesa-dev libxml2-utils xsltproc unzip

0.3 安装Repo

参考: http://source.android.com/source/downloading.html

$ mkdir ~/bin
$ vim .bashrc

在.bashrc中添加PATH=~/bin:$PATH
然后使设置生效:

$ . ~/.bashrc

下载repo:

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

1. 下载Android源代码

1.1 创建目录,存放代码用

$ mkdir android
$ cd android/

1.2 配置git

$ git config --global user.name "galian"
$ git config --global user.email "xxx@yyy.com"
$ git config -l
user.name=galian
user.email=xxx@yyy.com

1.3 查询Branch

参考: http://source.android.com/source/build-numbers.html#source-code-tags-and-builds

准备下载android-7.1.1_r13分支对应的代码。

1.4 repo init

repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.1_r13

一些log信息,如下:

$ repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.1_r13
Get https://gerrit.googlesource.com/git-repo/clone.bundle
Get https://gerrit.googlesource.com/git-repo
Get https://android.googlesource.com/platform/manifest% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404 Not Found
Server does not provide clone.bundle; ignoring.
remote: Counting objects: 410, done
remote: Total 4566 (delta 1251), reused 4566 (delta 1251)
接收对象中: 100% (4566/4566), 3.00 MiB | 2.60 MiB/s, 完成.
处理 delta 中: 100% (1251/1251), 完成.
来自 https://android.googlesource.com/platform/manifest* [新分支]          adt_23.0.3 -> origin/adt_23.0.3* [新分支]          afw-test-harness-1.5 -> origin/afw-test-harness-1.5* [新分支]          afw-test-harness-2.1 -> origin/afw-test-harness-2.1* [新分支]          afw-test-harness-marshmallow-dev -> origin/afw-test-harness-marshmallow-dev* [新分支]          afw-test-harness-nougat-dev -> origin/afw-test-harness-nougat-dev* [新分支]          android-1.6_r1 -> origin/android-1.6_r1* [新分支]          android-1.6_r1.1 -> origin/android-1.6_r1.1* [新分支]          android-1.6_r1.2 -> origin/android-1.6_r1.2(省略)* [新分支]          android-7.0.0_r24 -> origin/android-7.0.0_r24* [新分支]          android-7.0.0_r27 -> origin/android-7.0.0_r27* [新分支]          android-7.0.0_r3 -> origin/android-7.0.0_r3* [新分支]          android-7.0.0_r4 -> origin/android-7.0.0_r4* [新分支]          android-7.0.0_r5 -> origin/android-7.0.0_r5* [新分支]          android-7.0.0_r6 -> origin/android-7.0.0_r6* [新分支]          android-7.0.0_r7 -> origin/android-7.0.0_r7* [新分支]          android-7.1.0_r1 -> origin/android-7.1.0_r1* [新分支]          android-7.1.0_r2 -> origin/android-7.1.0_r2* [新分支]          android-7.1.0_r3 -> origin/android-7.1.0_r3* [新分支]          android-7.1.0_r4 -> origin/android-7.1.0_r4* [新分支]          android-7.1.0_r5 -> origin/android-7.1.0_r5* [新分支]          android-7.1.0_r6 -> origin/android-7.1.0_r6* [新分支]          android-7.1.0_r7 -> origin/android-7.1.0_r7* [新分支]          android-7.1.1_r1 -> origin/android-7.1.1_r1* [新分支]          android-7.1.1_r10 -> origin/android-7.1.1_r10* [新分支]          android-7.1.1_r11 -> origin/android-7.1.1_r11* [新分支]          android-7.1.1_r12 -> origin/android-7.1.1_r12* [新分支]          android-7.1.1_r13 -> origin/android-7.1.1_r13(省略)Your identity is: galian <xxx@yyy.com>
If you want to change this, please re-run 'repo init' with --config-nameTesting 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)? Yrepo has been initialized in /home/galian/android

1.5 开始下载代码

$ repo sync

大概需要5~6个小时可以下载完成。

注意:为了确保全下载下来,再多执行一次repo sync

android 7.0.1r13的代码大概54GB,其中.repo目录34GB。除去.repo目录,代码大概20GB左右。

2. 可能出现的问题

2.1 Network is unreachable

$ repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.1_r13
gpg: keyring `/home/galian/.repoconfig/gnupg/secring.gpg' created
gpg: keyring `/home/galian/.repoconfig/gnupg/pubring.gpg' created
gpg: /home/galian/.repoconfig/gnupg/trustdb.gpg: trustdb created
gpg: key 920F5C65: public key "Repo Maintainer <repo@android.kernel.org>" imported
gpg: key 692B382C: public key "Conley Owens <cco3@android.com>" imported
gpg: Total number processed: 2
gpg:               imported: 2  (RSA: 1)fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable

解决方法:
参考这个链接

$ sudo vim /etc/hosts

修改hosts文件后,执行

sudo apt-get install nscd
sudo /etc/init.d/nscd restart

2.2 unable to auto-detect email address

*** Please tell me who you are.Rungit config --global user.email "you@example.com"git config --global user.name "Your Name"to set your account's default identity.
Omit --global to set the identity only in this repository.fatal: unable to auto-detect email address (got 'galian@galian-VirtualBox.(none)')

解决方法:

$ git config --global user.name "your_name"
$ git config --global user.email "xxx@yyy.com"

替换your_namexxx@yyy.com为你自己的信息。

3. 参考

(1) http://source.android.com/source/index.html
(2) http://source.android.com/source/initializing.html
(3) http://source.android.com/source/downloading.html
(4) http://source.android.com/source/build-numbers.html#source-code-tags-and-builds

———————– 分 割 线 ———————–
本系列文章如下:

  • (1)《打造自己的Android源码学习环境之一:序》
  • (2)《打造自己的Android源码学习环境之二:在虚拟机中安装Ubuntu(上)》
  • (3)《打造自己的Android源码学习环境之三:在虚拟机中安装Ubuntu(下)》
  • (4)《打造自己的Android源码学习环境之四:下载Android源码》
  • (5)《打造自己的Android源码学习环境之五:编译Android源码》
  • (6)《打造自己的Android源码学习环境之六:运行Android模拟器》

打造自己的Android源码学习环境之四:下载Android源代码相关推荐

  1. 【Android开发】构建Android源码编译环境

    原文:http://android.eoe.cn/topic/android_sdk 构建Android源码编译环境 123456789 10 11 12 13 14 15 16 17 18 $ su ...

  2. 从零开始搭建Ubuntu 环境下的Android 源码开发环境

    本文从一个干净的Ubuntu 10.04 操作系统出发,一步一步引导你搭建自己的基于eclipse IDE 的Android源码开发环境. 正文会包含一下这些内容: 获得源码 编译源码准备工作 编译工 ...

  3. Android源码学习之浅析SystemServer脉络

    在之前的博文中<Android源码学习之如何创建使用JNI>和<Android源码学习之如何使用eclipse+NDK>中,浅谈了如何创建使用JNI和如何利用NDK工具开发创建 ...

  4. Android源码编译环境搭建教程 (一) - Ubuntu系统构建

    Android源码编译环境搭建教程 (一) - Ubuntu系统构建 本教程为感兴趣的同学提供Android源码编译的环境搭建,当然这里都是基于windows系统,mac系统也差不多,将相应的软件替换 ...

  5. 【Android 源码学习】 init启动

    目录 Android 源码学习 init启动 从main.cpp开始 init.cpp 部分逻辑 init启动zygote 属性服务 总结 Android 源码学习 init启动 Android 11 ...

  6. 【Android 源码学习】Zygote启动原理

    Android 源码学习 Zygote启动原理 望舒课堂 Zygote进程启动原理学习记录整理. Zygote简介 Zygote是进程在init进程启动时创建的,进程本身是app_process,来源 ...

  7. 【Android 源码学习】系统架构和启动流程

    Android 源码学习 系统架构和启动流程 望舒课堂 学习记录整理.以及以下参考文章的整理汇总.便于我个人的学习记录. 感谢IngresGe,Gityuan的精彩文章.为我们这些初探android系 ...

  8. 【Android 源码学习】SystemServer启动原理

    Android 源码学习 SystemServer启动原理 望舒课堂 SystemServer进程启动原理学习记录整理. 参考文章: Android系统启动流程(三)解析SyetemServer进程启 ...

  9. android源码学习-Toast实现原理讲解

    前言: 前些日志QQ群有朋友发了一个Toast的崩溃日志.Toast如此简单的用法怎么会崩溃呢?所以顺便就学习了一下Toast在源码中的实现,不算复杂,但内容挺多的,这里就来分享一下,方便读者. 一. ...

  10. Android源码学习之工厂方法模式应用

    主要内容: 工厂方法模式定义 工厂方法模式优势 工厂方法模式在Android源码中的应用 一.工厂方法模式定义 工厂方法模式定义: Define an interface for creating a ...

最新文章

  1. R语言缺失值替换:缺失的值(NA)替换每个分组最近的非缺失值
  2. ArrayMap java.lang.ArrayIndexOutOfBoundsException
  3. 学习PetShop3.0(3)模仿购物车的简单可变类
  4. nvidia驱动程序与windows版本不兼容
  5. Sql2000命名中的’_’好象会引发问题
  6. Windows 技巧篇-点开头的文件夹名创建方法。如何创建点开头的文件夹?
  7. mysql重连,连接丢失:The last packet successfully received from the server--转载
  8. autoencoder
  9. java中读取某路径下的文本内容
  10. Clustered Data ONTAP Fundamentals课程第一单元学习笔记(续3)
  11. WebPart中的ReplaceTokens 方法
  12. python求偏度系数_用 Python 讲解偏度和峰度
  13. settimeout需要清除吗_前端20个真正灵魂拷问,前端初级到中级你还需要这个!
  14. 四则运算表达式二叉树法求后缀表达式
  15. Nisus Writer Pro for Mac拆分视图和注释技巧
  16. [转载] Numpy_索引操作
  17. python中文字体奇怪_利用python检查 AS400的中文字问题
  18. 2021-10-25双塔模型
  19. matlab2019b的gui界面在哪_MATLAB(3)——GUI界面设计入门
  20. (转载)3. 飞控与惯性导航系统

热门文章

  1. mysql连17张表_mysql连表查询
  2. 汇编:1位16进制数到ASCII码转换
  3. SpringBoot06 统一响应格式
  4. BZOJ 4030: [HEOI2015]小L的白日梦
  5. [转]Spring 注解总结
  6. 【转】 Git 常用命令详解(二)----不错
  7. 《C语言到底能干什么》1.3 窗口程序的编写
  8. FPGA BCD计数器(一位)
  9. BACKPROPAGATION 手工求解
  10. Qt_QDbus用法