back to the beginning

Building and installing LineageOS 15.1 on Essential PH-1

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 do choose to build it yourself, you can also install the Google apps at any time.

Moving from stock Android to LineageOS or back again will require restoring your phone to factory settings. YOU WILL LOSE ALL YOUR DATA. YOU MUST COPY ANYTHING YOU VALUE OFF OF THE PHONE.

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

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

If you leave stock android, you will no longer have access to some features:


To flash back to stock:

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

Essential stock firmware and rom dumps


Required resources:

A quality USB cable and not the one provided with your phone.

TWRP modified by invisiblek

This will take a lot of disk space. A repo sync with all the other tools that get downloaded will require 180 GB space by the time you are finished building.

Websites for information and resources:

LineageOS 15.1 for the Essential PH-1 (mata) invisiblek's installation notes

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 platform-tools-latest-linux.zip -d ~

    To add these tools to your path add the following to ~/.profile

    # add Android SDK platform tools to path
    if [ -d "$HOME/platform-tools" ] ; then
    PATH="$HOME/platform-tools:$PATH"
    fi

    Run the following command to update your shell:

    source ~/.profile

  3. Install the build tools
  4. Note that with Ubuntu 18.04 libesd0-dev is not available. Just delete the last item and install the rest of the tools.

    sudo apt install bc bison build-essential ccache curl flex 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 pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev libesd0-dev

    Also install a Java Development Kit

    sudo apt install openjdk-8-jdk

  5. Download the git-repo tool
  6. mkdir -p ~/bin
    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo

  7. Download the LineageOS repository
  8. Note: You can use a base directory somewhere else. Mine is on a 240 GB SSD that I connect through a USB 3 enclosure.

    mkdir -p ~/android/lineage
    cd ~/android/lineage
    repo init -u https://github.com/LineageOS/android.git -b lineage-15.1
    repo sync
    source build/envsetup.sh
    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 when fast enough.

  9. Configure jack and root
  10. jack is required for building android 8.1 and LineageOS 15.1.

    Run the following command from your shell and add it to ~/.bashrc so it is set up for future use.

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

    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
  11. Add the Muppets
  12. 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 the 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
    croot
    brunch dragon

  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 cd $OUT

    In the folder there is is a file named lineage-15.1-20180601-UNOFFICIAL-mata.zip. 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

Items labeled FIRST TIME are also required for first time installations of LineageOS. If you are upgrading then do the items marked UPGRADE.

  1. FIRST TIME: Unlock the boot loader
  2. Installing LineageOS will require you have an unlocked boot loader. You only have to do this the first time.

  3. Reboot to recovery
  4. Restart the phone and depress the volume down button while the phone restarts. Alternately type the following in your shell and wait for the phone to restart:

    sudo adb reboot-bootloader

    To verify you can access the phone type:

    sudo fastboot devices

    If you see a device with the label "unathorized" you forgot to give your computer permission to access your phone through the adb interface.

  5. FIRST TIME: Wipe phone
  6. If you are coming from stock you will have to wipe your phone with this command (it will ensure the phone is erased):

    sudo fastboot -w

  7. UPGRADE: Switch slots
  8. If you are upgrading from a previous build of LineageOS then you can install to the second slot. If something goes wrong you will still be able to boot into your old version. sudo fastboot getvar current-slot
    sudo fastboot set_active other

  9. Install TWRP
  10. TWRP gets written to the boot partition.

    sudo fastboot flash boot twrp-mata_11.img

    Now press the volume down button to select booting to recovery and press the power button to select. After a few moments TWRP will start.

  11. Push images to device
  12. We need to push the OS image to the phone (the exact filename may vary):

    adb push lineage-15.1-date-UNOFFICIAL-mata.zip /sdcard/

    If you want to root with Magisk you also need to push Magisk to the phone as above but with the correct filename version.

    If you want to install gapps then download and push them to the phone as well.

  13. Flash desired images
  14. Once TWRP starts slide the switch and press the INSTALL button.

    Note: TWRP has a button to select if you want flash an .img or a .zip file. You have to use it to see the boot.img file and later the Magisk file on the /sdcard partion of your phone.

    Note: In TWRP you need to use the back button as well as the interface buttons for navigation.

    Use TWRP to select and flash the LineageOS image.

    Use TWRP to select and install gapps if desired.

    Use TWRP to select and install Magisk if desired.

  15. Reboot the phone without installing TWRP
  16. There is no need to have TWRP installed as an app on your phone.

  17. FIRST TIME: Boot loop
  18. If you phone boot loops or takes more than a few minutes to start into LineageOS then boot to recovery and reset to factory.

    To boot to recovery hold the volume up button down until the recovery menu appears. Use the volume buttons to select factory reset and the power button to execute. This will reset the phone and it will start properly.

  19. Disable USB debugging
  20. Settings - System - Developer options - USB debugging

    It is safest to keep USB debugging disabled until you need it. Go to the developer options menu in settings and disable it.

back to the beginning