环境搭建
1.安装64位Ubuntu系统(实体安装、虚拟机安装均可)
注意:要求机器至少4G内存(虚拟机至少分配4G内存),硬盘至少100G空间(源码20G+,编译后整个目录约60~70G)
安装方法请百度~
2.更新系统至最新版本,在终端下输入
- sudo apt-get update
- sudo apt-get upgrade
3.安装编译必需软件包
- sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop openjdk-7-jdk openjdk-7-jre pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
4.建立repo命令
- mkdir -p ~/bin
- curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
- chmod a+x ~/bin/repo
- echo "export PATH=~/bin:$PATH" >> ~/.bashrc
注意,第二行要从谷歌那里下载repo小程序,国内网络你懂的,可以在浏览器上面挂个代理通过以下地址下载好,拷贝到~/bin/repo,再执行第三行和第四行命令
- https://storage.googleapis.com/git-repo-downloads/repo
同步源码
1.新建一个储存源码的文件夹,这里以~/android/cm为例
- mkdir ~/android/cm
- cd ~/android/cm
2.初始化源码目录
- repo init -u git://github.com/CyanogenMod/android.git -b cm-12.1
3.添加红米3专用文件目录
- mkdir ~/android/cm/.repo/local_manifests
- gedit ~/android/cm/.repo/local_manifests/ido.xml
把以下内容复制进去
<?xml version="1.0" encoding="utf-8"?> <manifest> <project name="ido-dev/android_device_xiaomi_ido" path="device/xiaomi/ido" revision="cm-12.1" remote="github" /> <project name="ido-dev/proprietary_vendor_xiaomi" path="vendor/xiaomi" revision="cm-12.1" remote="github" /> <!-- <project name="ido-dev/android_kernel_xiaomi_ido" path="kernel/xiaomi/ido" revision="cm-12.1" remote="github" /> --> <project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" /> <project name="CyanogenMod/android_external_sony_boringssl-compat" path="external/sony/boringssl-compat" remote="github" /> <project name="CyanogenMod/android_external_stlport" path="external/stlport" remote="github" /> </manifest>
4.针对国内网络环境的处理(略自己使用VPN或者SS,教程请百度)
5.拉取代码(需要下载约十几个G的内容,花费时间参考各自网速)
- repo sync --no-clone-bundle
如果中间断网了,或者出错了,重新repo sync一下就可以继续了~
6.获取预编译的部分文件
- cd ~/android/cm/vendor/cm
- ./get-prebuilts
编译ROM
1.初始化编译环境
- cd ~/android/cm
- . build/envsetup.sh
- lunch cm_ido-userdebug
2.编译ROM(我笔记本下面虚拟机花费时间约2小时,取决于个人电脑性能)
- mka ido
注意:目前编译刚开始出现下面几行是正常现象,不影响的~
- find: ‘src‘: No such file or directory
- find: ‘phone/java‘: No such file or directory
- find: ‘dummy‘: No such file or directory
再次编译
1.建议每次编译都要把上一次编译的内容清除,否则有可能出现莫名其妙的问题
- make clobber
2.再次同步源码到最新版本
- repo sync
3.初始化编译环境
- . build/envsetup.sh
- lunch cm_ido-userdebug
4.编译ROM
- mka ido
一点贴士
开启ccache,加速编译过程
- export USE_CCACHE=1
时间: 2024-10-11 09:51:24