Home

About ゴジラ

Building CyanogenMod 14 from source

Note This guide contains parts that are specific to building CyanogenMod for the OnePlus 3, do read the commands and make necessary adjustments for different devices. Do NOT try to install CyanogenMod built from this guide on any other phone, it may lead to a bricked device!

Prerequisites:

Ubuntu 16.04 operating system (14.04 and below might possibly work too)

Around 100 GB of free disk space -- You can work with ~70-80 GB, but it's ideal to have around 100 GB

Install the build tools

Let's update up the apt lists first,

apt-get update

Install specific build tools,

apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev bc git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng

Note if using a 64bit build of Ubuntu, You'll also need to install,

apt-get install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev

Java

CyanogenMod 14 requires OpenJDK 8 (Java 8) to be built. We'll need to install this as well,

apt-get install openjdk-8-jdk

Setting up the environment

Create the folder you'll be downloading the source code into,

mkdir -p ~/android/system

Download the "repo" tool, the repo tool is used to download and sync the source code,

curl https://storage.googleapis.com/git-repo-downloads/repo > /bin/repo chmod a+x /bin/repo

Enter into the Source code directory and initialize the repository,

cd ~/android/system/ repo init -u https://github.com/CyanogenMod/android.git -b cm-14.0

Downloading the source code

To download the CyanogenMod source code, run the following command,

repo sync

This step will take a while as it downloads around ~35 - 40 GB of data, I'd recommend using a Virtual Machine at a cloud/VM provider or a machine with a high speed internet connection to proceed.

Building for a specific device

I usually build under a "screen" as I'm building on a remote machine, so that SSH disconnects don't affect the build. So let's enter into a "screen",

screen

In this guide, I'm building CyanogenMod for the OnePlus 3, so I use the device name "oneplus3" here to specify building CyanogenMod for the OnePlus 3

source build/envsetup.sh breakfast oneplus3

Loading in the device specific blobs

Edit the roomservice.xml file to ensure it has all the correct repos listed,

nano ~/android/system/.repo/local_manifests/roomservice.xml

And make sure it contains the following,

<?xml version="1.0" encoding="UTF-8"?> <manifest> <project name="CyanogenMod/android_device_oppo_common" path="device/oppo/common" remote="github" revision="cm-14.0" /> <project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" revision="cm-14.0" /> <project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" revision="cm-14.0" /> <project name="CyanogenMod/android_device_oneplus_oneplus3" path="device/oneplus/oneplus3" remote="github" revision="cm-14.0" /> <project name="CyanogenMod/android_kernel_oneplus_msm8996" path="kernel/oneplus/msm8996" remote="github" revision="cm-14.0" /> <project name="CyanogenMod/android_external_sony_boringssl-compat" path="external/sony/boringssl-compat" remote="github" revision="cm-14.0" /> <project name="CyanogenMod/android_external_stlport" path="external/stlport" remote="github" revision="cm-14.0" /> <project name="CyanogenMod/android_vendor_nxp-nfc_opensource_Nfc" path="vendor/nxp-nfc/opensource/Nfc" remote="github" revision="cm-14.0" /> <project name="CyanogenMod/android_vendor_nxp-nfc_opensource_frameworks" path="vendor/nxp-nfc/opensource/frameworks" remote="github" revision="cm-14.0" /> <project name="CyanogenMod/android_vendor_nxp-nfc_opensource_libnfc-nci" path="vendor/nxp-nfc/opensource/libnfc-nci" remote="github" revision="cm-14.0" /> </manifest>

The "TheMuppets/proprietary_vendor_oneplus" line is important, as it contains all the proprietary blobs for the OnePlus 3.

Save the file and then run a sync again,

cd ~/android/system/ repo sync

It shouldn't take long this time, as it only downloads the proprietary blobs.

Speed up the building process

This is highly recommended by CyanogenMod, to reduce the amount of time taken by the build process,

export USE_CCACHE=1 prebuilts/misc/linux-x86/ccache/ccache -M 50G

Building CyanogenMod (Finally!)

Finally, start building CyanogenMod,

brunch oneplus3

The initial build will take sometime to complete, around 35 - 40 minutes is what it took me. You can "detach" from the screen by hitting CTRL+A+D and then "reconnect" to the screen with the command "screen -r". Detaching from the screen will not affect the building process, it will continue in the background.

Last modified: December 06 2019 14:21:55