1、 前期准备:
安装Ubuntu,
下载源码,很多地方需要翻墙,本人使用的是配置hosts文件,仅供参考
安装编译源码所需要的工具集
这些工具集务必要提前安装好,否则会编译出错,且难以排查,导致浪费时间。你可以依次安装软件也可以一次性安装(建议依次安装,这样抱错的话能够及时有针对性的排除)。
sudo apt-get install git-core
sudo apt-get install git
sudo apt-get install gnupg
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install gperf
sudo apt-get install build-essential
sudo apt-get install build-essential
sudo apt-get install zip
sudo apt-get install curl
sudo apt-get install libc6-dev
sudo apt-get install libncurses5-dev:i386
sudo apt-get install x11proto-core-dev
sudo apt-get install libx11-dev:i386
sudo apt-get install libreadline6-dev:i386
sudo apt-get install libgl1-mesa-dev
sudo apt-get install g++-multilib
sudo apt-get install mingw32
sudo apt-get install tofrodos
sudo apt-get install python-markdown
sudo apt-get install libxml2-utils
sudo apt-get install xsltproc
sudo apt-get install zlib1g-dev:i386
sudo apt-get install dpkg-dev
** 安装 Git **(我的是系统自带装好) 可以输入 git --version 如果输出版本等信息则已经安装。没有安装的网上很多安装资料。并且设置git 的global user.name 和 user.email
$ git config --global user.name "Your Name"
$ git config --global user.email "you@example.com"
** 安装curl**
$ curl sudo apt-get install curl
下载repo脚本文件:
<1>创建保存脚本的文件:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
<2>下载repo工具并保证可执行
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
2、开始下载
**<1>创建保存源码的文件夹,并进入 **
$ mkdir Android
$ cd Android
** <2>执行repo init 之前必须指定manifest的URL,此时下载的android源码,自动匹配最新版本源码**
$ repo init -u https://android.googlesource.com/platform/manifest
<3>.下载指定版本源码,在<2>的命令后加 -b 版本分支名
如下
$ repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.2_r27
** <4>下载**
$ repo sync
下载的时间比较长,并且很可能中途停止,只要在repo sync 就可以接着下载,我下载了三四天,网速不太好。