0.参考链接
我是根据https://source.android.com/source/initializing.html进行环境搭建,里面很详细,还有jdk,jre的下载地址。
1. 环境
1.1 编译环境
Android N需要使用Java 8进行编译
Download the.debpackages for 64-bit architecture fromarchive.ubuntu.com:
openjdk-8-jre-headless_8u45-b14-1_amd64.debwith SHA2560f5aba8db39088283b51e00054813063173a4d8809f70033976f83e214ab56c0
openjdk-8-jre_8u45-b14-1_amd64.debwith SHA2569ef76c4562d39432b69baf6c18f199707c5c56a5b4566847df908b7d74e15849
openjdk-8-jdk_8u45-b14-1_amd64.debwith SHA2566e47215cf6205aa829e6a0a64985075bd29d1f428a4006a80c9db371c2fc3c4c
Optionally, confirm the checksums of the downloaded files against the SHA256 string listed with each package above.
For example, with thesha256sumtool:
$ sha256sum{downloaded.deb file}
Install the packages:
$ sudo apt-getupdate
Rundpkgfor each of the .deb files you downloaded. It may produce errors due to missing dependencies:
$ sudo dpkg-i{downloaded.deb file}
To fix missing dependencies:
$ sudo apt-get-f install
1.2 更新默认的java环境
$sudoupdate-alternatives --config java
$sudoupdate-alternatives --config javac
要编译Android N相关代码时,需要java 和 javac 都切换成 java-8-openjdk。
如果需要编译Android M相关代码时,还需要调用上面命令,切换成java-7-openjdk。貌似不需要
1.3 安装需要的包
$sudoapt-getinstallgit-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