编译环境准备
编译环境
uname -a
Linux wonfee-ThinkPad-T540p 3.16.7-ckt5my-very-own-kernel #1 SMP Fri Feb 27 23:04:29 CST 2015 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/issue
Ubuntu 14.04.2 LTS \n \l
java -version
java version “1.6.0_30”
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
安装其他必要的库
该部分可参考android源码官方编译文档,若已成功编译过android源码,则该部分的库应该都已经安装。
sudo apt-get install bison build-essential curl flex \
g++-multilib gcc-multilib git-core gnupg gperf \
lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev \
libesd0-dev libncurses5-dev libsdl1.2-dev \
libwxgtk2.8-dev libxml2 libxml2-utils lzop \
openjdk-6-jdk openjdk-6-jre pngcrush schedtool \
squashfs-tools xsltproc zip zlib1g-dev
下载cm源码
参考: CyanogenMod Source Code Download
下载好cm-11源码后,如果要编译此时还需要下载其所支持机型相关的device、kernel等代码, 这里以官方所支持的nexus7机型作为测试。
从cm官方的github页面[cm-github][2]搜索grouper可以看到还需要下载device和kernel部分,分别为android_device_asus_grouper、android_kernel_asus_grouper,
mkdir -p device/asus/ && cd device/asus
git clone https://github.com/CyanogenMod/android_kernel_asus_grouper.git grouper
cd ../../
mkdir -p kernel/asus && cd kernel/asus/
git clone https://github.com/CyanogenMod/android_device_asus_grouper.git grouper
编译CM-11 源码
source build/envsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/goldfish/vendorsetup.sh
including device/generic/mips/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including vendor/cm/vendorsetup.sh
including sdk/bash_completion/adb.bash
including vendor/cm/bash_completion/git.bash
including vendor/cm/bash_completion/repo.bash
breakfast grouper
Download the necessary prebuilts from cyanogenmod by running
cd verdor/cm/
. get-prebuilts
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 178 100 178 0 0 229 0 --:--:-- --:--:-- --:--:-- 229
100 551k 100 551k 0 0 265k 0 0:00:02 0:00:02 --:--:-- 1531k
Archive: ./proprietary/Term.apk
inflating: ./proprietary/lib/armeabi/libjackpal-androidterm5.so
inflating: ./proprietary/lib/mips/libjackpal-androidterm5.so
inflating: ./proprietary/lib/x86/libjackpal-androidterm5.so
inflating: ./proprietary/lib/armeabi/libjackpal-termexec2.so
inflating: ./proprietary/lib/mips/libjackpal-termexec2.so
inflating: ./proprietary/lib/x86/libjackpal-termexec2.so
croot
Building the ROM
brunch grouper
running: java -Xmx2048m -jar /data/Android/Cyanogenmod/out/host/linux-x86/framework/signapk.jar -w build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8 /tmp/tmpFcHrQD /data/Android/Cyanogenmod/out/target/product/grouper/cm_grouper-ota-387c0dd2e4.zip
done.
Package Complete: /data/Android/Cyanogenmod/out/target/product/grouper/cm-11-20150824-UNOFFICIAL-grouper.zip
注意事项:
- 若编译环境有配置NDK_ROOT环境变量,则编译前需要取消该环境变量unset NDK_ROOT, 否则编译会直接如下报错;
build/core/base_rules.mk:134: * external/webrtc/src/system_wrappers/source: MODULE.TARGET.STATIC_LIBRARIES.libwebrtc_system_wrappers already defined by external/webrtc/src/system_wrappers/source. Stop.
build error!