To build LineageOS, you’ll need:
sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev
For Ubuntu versions older than 16.04 (xenial), substitute:
libwxgtk3.0-dev → libwxgtk2.8-dev
Java
Different versions of LineageOS require different JDK (Java Development Kit) versions.
- LineageOS
14.1-15.1: needOpenJDK 1.8
sudo apt install openjdk-8-jdk
sudo apt install openjdk-8-jreYou’ll need to set up some directories in your build environment.
To create them:
mkdir -p ~/bin mkdir -p ~/android/lineageThe ~/bin directory will contain the git-repo tool (commonly named “repo”) and the ~/android/lineage directory will contain the source code of LineageOS.
Enter the following to download the repo binary and make it executable (runnable):
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repoIn recent versions of Ubuntu, ~/bin should already be in your PATH. You can check this by opening ~/.profile with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fiThen, run source ~/.profile to update your environment.
Initialize the LineageOS source repository
cm-14.1
Enter the following to initialize the repository:
cd ~/android/lineagerepo init -u git://github.com/LineageOS/android.git -b cm-14.1To start the download of the source code to your computer, type the following:
repo syncAfter the source downloads, ensure you’re in the root of the source code (cd ~/android/lineage), then clone your device sources with the following commands :
device tree :
git clone https://github.com/DhirajSurvase/android_device_Moto-C-plus -b cm-14.1 device/moto/panellikernel source :
git clone https://github.com/DhirajSurvase/kernel-Moto-C-plus -b cm-14.1 kernel/moto/panellivendor blobs :
git clone https://github.com/DhirajSurvase/android-vendor-Moto-C-plus -b cm-14.1 vendor/moto/panellithen type:
source build/envsetup.sh
# set up the Moto C-plus code
lunch lineage_panelli userdebug
# To Build the `ROM`(Lineage 14.1)
croot
brunch panelli Make use of ccache if you want to speed up subsequent builds by running:
export USE_CCACHE=1and adding that line to your ~/.bashrc file. Then, specify the maximum amount of disk space you want ccache to use by typing this:
ccache -M 50Gwhere 50GB corresponds to 50GB of cache. This needs to be run once. Anywhere from 25GB-100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s Android build environment initialization page.
You can also enable the optional ccache compression. While this may involve a slight performance slowdown, it increases the number of files that fit in the cache. To enable it, run:
export CCACHE_COMPRESS=1or add that line to your ~/.bashrc file.
Note: If compression is enabled, the ccache size can be lower (aim for approximately
20GBfor one device).
Jack is the currently used Java toolchain for building LineageOS 14.1 and up. It is known to run out of memory often if not configured correctly - a simple fix is to run this command:
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"Adding that command to your ~/.bashrc file will automatically configure Jack to allocate a sufficient amount of memory (in this case, 4GB).
source build/envsetup.sh
# set up the Moto C-plus code
lunch lineage_panelli userdebug
# To Build the `ROM`(Lineage 14.1)
croot
brunch panelli