CentOS7上编译Android系统

下载 repo 工具

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

编辑~/bin/repo文件,将REPO_URL由

https://gerrit.googlesource.com/git-repo
改为
https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

下载Android源代码

# 下载源码包
$ wget https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar
$ tar xf aosp-latest.tar

同步代码

$ cd aosp
$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
$ repo sync

也可以同步指定branch的代码

$ cd aosp
$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-6.0.1_r1
$ repo sync

准备编译环境

安装需要的库

$ sudo yum install -y gcc make libstdc++.i686 libstdc++-devel.i686 zlib-devel openssl-devel perl cpio expat-devel gettext-devel autoconf glibc.i686 glibc-devel.i686 zlib-devel.i686 libstdc++.i686 libX11-devel.i686 ncurses-devel.i686 ncurses-libs.i686 gperf flex gcc-c++ bison patch

安装java库

$ sudo yum install -y java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64 java-1.7.0-openjdk-headless.x86_64

或者

$ sudo yum install -y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 java-1.8.0-openjdk-headless.x86_64

编译

# source 环境
$ . build/envsetup.sh

# 选择编译项目
$ lunch 2

# 编译,可以使用-j选项设置并行编译的数量
$ make -j8

参考:

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

你可能感兴趣的:(CentOS7上编译Android系统)