Installing LineageOS and gAPPS on Nexus 5X

Notes and Disclaimer

Obligatory Disclaimer: This guide is provided without any warranty. I am not responsible for any bricked devices. LineageOS Nightly Builds are considered unstable and should not be used on production devices. Only use this guide if you know what you are doing and if you know how to recover a messed up Android device!

In order to enable all features of the device we will have to flash vendor.img on top of the installed LineageOS, otherwise things like the camera and the rotation sensor won't work. This guide is based on the current Nightly build 20170213-bullhead-nightly-signed. You will need stock image 7.1.1 (N4F26O).

I will be skipping over the parts where you unlock the bootloader and flash a custom recovery because this article is targeted at advanced users who have already set up a custom ROM on their device before, for example CyanogenMod. I may cover those steps in a separate article.

Prerequisites

  • Current ADB and Fastboot
  • Current TWRP Recovery installed on the device (at least 3.0.2-3)
  • Unlocked Bootloader
  • TitaniumBackup
  • Newest LineageOS 14.1 Nightly Build for Nexus 5X (bullhead)
  • Current OpenGAPPS for Android 7.1 arm64 pico
  • LineageOS su Addon (from https://download.lineageos.org/extras)
  • Newest factory image of Android 7.1 for Nexus 5X (bullhead)

Preparations

  • Make a TitaniumBackup backup of all apps you want to keep.
  • Backup your userdata (Photos, Contacts, Calendar etc.), be sure you have backed up everything, we are going to be deleting ALL data from this device.
  • Boot into the TWRP Recovery, if possible make a complete backup there, and transfer it to the PC. You will use this if anything goes wrong.

  • Unzip the Factory Image, and the ZIP file inside. We are interested in the vendor.img file.

Step 0 – Wipe the Device

In TWRP choose Wipe->Advanced Wipe->Tick every option.
ATTENTION! This will irreversibly erase all data from your device!

Step 1 – Transfer the files to the device

While in TWRP use ADB to transfer the following files:

  1. LineageOS
    adb push /path/to/lineageOS.zip /sdcard/
  2. OpenGAPPS
    adb push /path/to/opengapps.zip /sdcard/
  3. LineageOS su Addon
    adb push /path/to/suAddon.zip /sdcard/

Step 2 – Install the Files using TWRP

In TWRP Recovery install the files you just copied in this order. Do not reboot in between!

  1. LineageOS
  2. OpenGAPPS
  3. LineageOS su Addon

Afterwards choose to clear the Dalvik Cache and use ADB to reboot to Fastboot (bootloader)

adb reboot bootloader

Step 3 – Flash the Vendor.img

Use Fastboot to flash the Vendor.img you extracted from the Stock Image

fastboot flash vendor /path/to/vendor.img

Step 4 – Boot the Device

  1. Power off the device.
  2. Remove the SIM-card from your device. This is important because there is currently a bug where you will enter a setup loop if the device has network connectivity during setup.
  3. Power on the device.
  4. Use the Setup Wizard to setup the device however you please, but again do not enable WiFi, to avoid the same bug I mentioned in #2.

After completing the setup wizard you can re-insert the SIM-card and connect your Nexus 5X to wifi.

This concludes the main steps of this guide, but there are some optional steps I'd recommend doing.

Optional steps and remarks

  • Check if your device is working as expected, pay special attention to the camera app and the rotation sensor. If any of those aren't working, try repeating step 3.

  • Enable Developer Options. To do this, go to Settings->About phone, now tap on the build number seven times, or until you get a message that Developer Options are enabled. In the Developer Options you can do things like enable root or ADB debugging.

  • LineageOS currently has a bug, which can lead to malfunctioning phone (symptoms: Home Button not working, App Switcher (and button) not working, Back Button is still working), when you play around with/try to use system profiles.

  • Restore the TitaniumBackup backup.