下载android系统源码和编译–从清华源下载源码
系统
ubuntu16.04
每次都要各种百度,然后再一次记录,索性这次在编译xposed和android系统源码时一次性全部记录下。包括如何设置清华源,如何下载指定的版本、如何编译不同版本所需要的环境支持等,以及刷真机需要的文件和注意事项。
在编译和刷机之前要先下载源码和刷机需要的文件。首先设置下载源环境。因为国内需要fq的操作,所以这里选用清华源来。
#设置源环境
下载使用的清华源的就可以了,步骤:
1、下载repo脚本
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
2、添加REPO_URL到~/.bashrc文件中
gedit ~/.bashrc
在最后添加
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
或者直接在cmd中输入上面的export 命令即可,不用修改~/.bashrc文件
保存退出,生效当前的配置脚本
source ~/.bashrc
注意
在修改了~/.bashrc之后,最好关闭掉当前的窗口,重新开一个
3、安装git和配置git
sudo apt-get install git
git config --global user.email "填写邮箱地址"
git config --global user.name "你要用的名称"
之所以要配置是因为使用repo的时候要用
4、查看所有android源码分支
首先初始化repo
$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
然后在执行git branch -a 查看所有分支。
git branch -a
5、选择下载分支
$ mkdir -p ~/android/android-6.0.0_r1
$ cd ~/android/android-6.0.0_r1
$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-6.0.0_r1 --depth=1
--depth=1 表示只会提取最新的版本,避免将整个源码的历史版本都是提取出来,在android6.0以上会有问题&#