[G 2014 General] mankokoma:
LineageOS is in an official state, so that's for the ones with no patience, like me. I want my nightlies!! So DIY!!

This is not about flashing. Only how to build a ROM in an Ubuntu (meanwhile Debian 8) environment! So I have nothing to do with what you do with the finished Zip-file.

I am not responsible for your phone or your computer! Everything you read here resulting in taking action is at your own risk!

All credits go to all devs and supporters here on XDA, CyanogenMod / LineageOS for all their work they provide for free on github. We just take thankful the benefit!! Mainly LuK1337 provided the best hints and informations!

## These sites will help you:

http://wiki.lineageos.org/titan_build.html

http://web.archive.org/web/20160722172103/http://wiki.cyanogenmod.org/w/Envsetup_help

http://web.archive.org/web/20160421170720/http://wiki.cyanogenmod.org/w/Build_for_titan

http://gojira.tokyo/?building_cyanogenmod_14_from_source

http://source.android.com/source/initializing.html

## GIT and repos

https://xdaforums.com/showthread.php?t=2329228

## SET UP THE ENVIRONMENT

## Install (in VMware Player or Virtualbox?) 64-bit-Ubuntu 16.04.1 LTS / 8GB RAM / 100GB HDD

## All following is done in a terminal

## These are the packets you need (if you use debian some will fail (e.g. JAVA) -take them out of the list manually):

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

## To install JAVA 8 in Debian:

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer

## Add all needed paths and the ccache command (following two lines) to the end of ~/.bashrc

## copy the whole box to your terminal and the lines will be added...

echo "export PATH=~/bin:~/android/lineageos/toolchain:~/android/lineageos/external/v8/build/toolchain:~/android/lineageos/prebuilts/sdk/tools:$PATH
export USE_CCACHE=1" >> ~/.bashrc

## Maybe here is a good point to restart the Ubuntu machine once...

## I'm not sure if necessary you need an account at https://github.com but it complains when not...

git config --global user.email "your-GIT-REG-email"
git config --global user.name "your-GIT-REG-username"

mkdir -p ~/bin
mkdir -p ~/android/lineageos/
mkdir -p ~/android/lineageos/.repo/local_manifests

## get the repo command

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

## The right git-repos to sync are in: ~/android/lineageos/.repo/local_manifests/roomservice.xml

## copy the whole box into the terminal and the roomservice.xml will be written:

echo "<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch="ssh://git@bitbucket.org" name="bitbucket" />
<remote fetch="ssh://git@gitlab.com" name="gitlab" />
<remote fetch="git://codeaurora.org/" name="caf" review="codeaurora.org" sync-c="true" />
<project name="LineageOS/android_device_motorola_titan" path="device/motorola/titan" remote="github" />
<project name="LineageOS/android_device_motorola_thea" path="device/motorola/thea" remote="github" />
<project name="LineageOS/android_device_motorola_msm8226-common" path="device/motorola/msm8226-common" remote="github" />
<project name="LineageOS/android_device_qcom_common" path="device/qcom/common" remote="github" />
<project name="LineageOS/android_kernel_motorola_msm8226" path="kernel/motorola/msm8226" remote="github" />
<project name="LineageOS/android_packages_resources_devicesettings" path="packages/resources/devicesettings" remote="github" />
<project name="TheMuppets/proprietary_vendor_motorola" path="vendor/motorola" remote="github" />
<project name="TheMuppets/proprietary_vendor_qcom_binaries" path="vendor/qcom/binaries" remote="github" />
<project name="TheMuppets/proprietary_vendor_asus" path="vendor/asus" remote="github" />
</manifest>" > ~/android/lineageos/.repo/local_manifests/roomservice.xml

## Get the github to the machine

repo init -u git://github.com/lineageos/android.git -b cm-14.1

## additional folders to put the repos and binaries for building

## O.K. lets start the first try

cd ~/android/lineageos/
source build/envsetup.sh

repo sync

## Wait VERY LONG (really hours) and IF STUCKS, press "ctrl+C" and once more "repo sync" again.

## Then Extract proprietary blobs from the phone

## the device must be connected via USB cable (adb has to be functional) and go to the TITAN directory:

cd ~/android/lineageos/device/motorola/titan

## and

./extract-files.sh

## and maybe (only once before the first time of building) configure the CCACHE, which makes compiling much faster:

prebuilts/misc/linux-x86/ccache/ccache -M 50G

##WHEN ALL IS DONE

## we now can forget all steps before! ...Until we run in trouble - then look at the bottom or restart from scratch.

## In my experience now it shows, that the compiling processes recompiles and replaces "new synced packets" in the out-directory and leave the untouched untouched. So we can (nearly) always restart a broken build process... maybe the devs will VETO this. Some delete the whole out-directory every time - I think you can easily start over ;)

## However, what we should do everytime before we start building is:

cd ~/android/lineageos/
source build/envsetup.sh
repo sync

## OKAY, lets build.... Nooooooo! Not yet!

## The most Important question now:

## "Do you want to have a ROOTED phone?" If yes, then you have to

export WITH_SU=true

## If you don't want root then just start with:

brunch titan

## Now you can wait again for hours and hopefully got finished

## ~/android/lineageos/out/target/product/titan/lineage-14.1-2017****-UNOFFICIAL-titan.zip

------------------------------------------------------------------------

------------------------------------------------------------------------

## TROUBLE with compilation stops / stucks with error:

## JACK-SERVER error:

## reinstall the Jack Server

cd ~/android/lineageos/prebuilts/sdk/tools
jack-admin kill-server
jack-admin uninstall-server
jack-admin install-server jack-launcher.jar jack-server-4.8.ALPHA.jar

## sometimes a permission problem:

chmod 700 ~/.jack-server
find ~/.jack-server -type f -print0 | xargs -0 chmod 600
chmod 664 ~/.jack-settings

##Also helpful if Java stops compiling is to limit the usage of RAM:

export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"

##NINJA error:

## increase RAM of VM, or you cant put

export USE_NINJA=false

command to the .bashrc

## APPS/org.cyanogenmod.platform-res_intermediates error:

javac: file not found: ~android/lineageos/out/target/common/obj/APPS/org.cyanogenmod.platform-res_intermediates/src/cyanogenmod/platform/Manifest.java
Usage: javac <options> <source files>
use -help for a list of possible options
ninja: build stopped: subcommand failed.
build/core/ninja.mk:151: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1
make: Leaving directory '~/android/lineageos'
#### make failed to build some targets (25:19 (mm:ss)) ####

When this happens, give a:

mka org.cyanogenmod.platform-res

This also works for most other Errors, which stop the process... Find the line with "****_intermediate" and give the "mka ****" WITHOUT the "_intermediate".

After compiling of the single package is finished - once more:

brunch titan

## New one: *** This repo is now deprecated. Move your blobs to your device's vendor repo..

find: "~/android/lineageos/out/target/common/obj/SHARED_LIBRARIES/libwifi-hal-mock_intermediates": Datei oder Verzeichnis nicht gefunden
build/core/package_internal.mk:143: Empty argument supplied to find-subdir-assets
./vendor/qcom/binaries/Android.mk:1: *** This repo is now deprecated. Move your blobs to your device's vendor repo..

The solution is given here by mirkosrc:

~/android/lineageos$ mv vendor/qcom/binaries/Android.mk vendor/qcom/binaries/Android.mk.bak

Now we have the proper solution given by kessaras in post #37 (thanks a lot!!):

## LAST OPTION:

When nothing works at all anymore you can delete the whole content of the out-folder:

rm -rf ~/android/lineageos/out/*

But then the first compiling last very long again...

## If the DISK runs full,

look into android/lineageos/out/target/product/titan/obj/PACKAGING/target_files_intermediates and delete the files...

## repo sync crashes with error:

repo sync -j1 -f --force-sync

------------------------------------------------------------------------