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