1) Establish build environment
https://source.android.com/source/initializing
Ubuntu-16.04 64bit in VirtualBox
Increase swap size if system memory is small (e.g.: 3GB system memory with 18GB swap)
Recommend 180GB or above disk space
$sudo apt-get update
$sudo apt-get install openjdk-8-jdk
$sudo apt-get install git-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
[ Optional ] Install openjdk-7 for old ver AOSP (e.g. 5.x - lollipop)
$sudo add-apt-repository ppa:openjdk-r/ppa
$sudo apt-get update
$sudo apt-get install openjdk-7-jdk
$sudo update-java-alternatives -l
##set jname
$sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
2) Download the source
https://source.android.com/source/downloading
$mkdir ~/bin
$PATH=~/bin:$PATH
$curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$chmod a+x ~/bin/repo
$mkdir -p android
$cd android
$git config --global user.name "Your Name"
$git config --global user.email "you@example.com"
$repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.2_r27
$repo sync
[ Remark] Please ignore the following error message:
*curl: (22) The requested URL returned error: 404* *Server does not provide clone.bundle; ignoring.*
3) Preparing to Build
https://source.android.com/source/building
$. build/envsetup.sh
[ Remark ] Increase heap size to avoid the following error message.
Cannot connect to jack-server / heap size is small.
$export PATH=$PATH:~/.jack-server
$export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
$./prebuilts/sdk/tools/jack-admin kill-server
$./prebuilts/sdk/tools/jack-admin start-server
[ Remark ] Apply the patch first if using lolllipop version:
https://stackoverflow.com/questions/36048358/building-android-from-sources-unsupported-reloc-43/36073635
[Remark] Remember to clean the project after the makefile (*.mk) or configuration is changed
$make clean
$lunch
$make -j4
[ Remark ] Since pre-built libwebviewchromium.so module does NOT exist in the lollipop or previous version, it takes long time to build this module.
After success, the img can be found at:
<aosp>/out/target/product/<target>/
沒有留言:
發佈留言