back to the beginning

Building LineageOS on Essential PH-1

Last updated: 2019-01-23 (Migrating instructions from 15.1 -> 16 (things may break))

This page is for building LineageOS 16 (I recommend staying on 15.1 for now.)

On 2019-01-16 the code still had issues: see log

LineageOS 15.1 build instructions.

LineageOS is an alternate version of the Android operating system for your phone. Rather than building it yourself the first time, I recommend you use the image provided by invisblek). However, his image includes Google apps by default. If you want to experience life without Google's apps you will have to build LineageOS yourself. If you want to use Google apps, then use get LineageOS from here. You can still use these instructions to install.

WARNING: Moving from stock Android to LineageOS (including builds from various sources that use different build keys!) or back again will require restoring your phone to factory settings.

LineageOS is still in development and some features are not working.

LineageOS features still not working (most notable for me):

To flash back to stock:

If you want to remove LineageOS and return to stock Android follow the instructions here:

You will lose all your data so make a backup beforehand (see step for that below).

Required resources:

Websites for information and resources:

Prerequisites and required software:

All instructions assume you are running Linux. These instructions are for Ubuntu with minimum version of 16.04.

  1. Prepare build environment
  2. You will need to install proper ADB (Android Debugging Bridge) tools for your platform. For Ubuntu 18.04 this is as simple as running

    sudo apt install adb

    If your distribution provides out of date tools you can obtain them directly from Google.

    Install the tools from Google:

    unzip -d ~

  3. Add these tools to your path add the following to ~/.profile
  4. # add Android SDK platform tools to path
    if [ -d "$HOME/platform-tools" ] ; then

    Run the following command to update your shell:

    source ~/.profile

  5. Install the build tools
  6. sudo apt install -y bc build-essential ccache curl g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop m4 openjdk-8-jdk pngcrush repo rsync schedtool squashfs-tools xsltproc zip zlib1g-dev

    If you get a version error with java, change the active one to version 8:

    sudo update-alternatives --config java

  7. Download the git-repo tool
  8. mkdir -p ~/bin
    curl > ~/bin/repo
    chmod a+x ~/bin/repo

  9. Download the LineageOS repository
  10. Note: You can use a base directory somewhere else.

    mkdir -p ~/android/lineage
    cd ~/android/lineage
    repo init -u -b lineage-16.0
    repo sync
    source build/
    breakfast mata

    Note: mata is the code name for the Essential PH-1. If you see other tutorials for building LineageOS you can follow their instructions but use mata where necessary. I suggest you look up another tutorial since I am leaving out instructions on using ccache. Apparently it can speed up your build but I did not want to commit even more disk space to the project. My desktop has 32 GB of RAM and I felt the build was fast enough.

  11. Configure root
  12. If you want to build root into your LineageOS image then also run the following and also add it to ~./bashrc

    export WITH_SU=true

  13. Add the Muppets
  14. We will use the muppets repository to bring in all the extra bits required for the mata build rather than obtain them from the phone itself.

    Add the following bit to the file located at ~/android/lineage/.repo/local_manifests/roomservice.xml

    <project name="TheMuppets/proprietary_vendor_essential" path="vendor/essential" />

Build LineageOS:

  1. Build commands:
  2. In the future consider all of the above are things you don't have to do next time. Anytime you want to build just start here. You only have to run repo sync when you want to make sure you have the lastest code. We need to run it now to pull stuff in from the Muppets.

    cd ~/android/lineage
    repo sync [if on rebuilding you receive error try: repo sync --force-sync]
    source build/
    brunch mata

  3. Installation files
  4. Once you manage an error free build you can quickly go to the directory where your LineageOS image is located by typing this:

    cd $OUT

    In the folder there is is a file named The name will be based on the date you built LineageOS.

    There is also a boot.img that you can use to install Magisk if you want to gain root that way at a later time.

Installing LineageOS

back to the beginning

Something need fixing? Contact me: