HTC One M9 to Lineage OS 14.1 (Android 7.1.2)

Image Credits: HTC Corporation, Lineage OS

I have a HTC One M9 here at the office we have been using for Android development. It was a trade for a bunch of my older computer hardware, otherwise I probably would have bought a Nexus. It is a great phone, but I have never been a fan of HTC Sense. Additionaly, having a custom UI/UX on the phone makes it harder to judge if an app's appearance is consistant with the current Android UI/UX.

Being a tinkerer at heart, I decided to flash a custom ROM on the phone. In the past, I had used CyanogenMod flash my Samsung Galaxy SII. Unfortunately, it appears to no longer exist. Its successor, Lineage OS, does appear to be in active development.

Unlock the Device

This was a locked phone, so the first step was to unlock the bootloader. HTC allows this via the website. After creating an account and selecting my device, I was given a quick set of instructions on unlocking the device. Here is a summary (this is for Linux, Mac/Windows will be similar):

  1. Install fastboot if necessary (or HTC provides a binary): 
    sudo apt-get install android-tools-fastboot
  2. On the phone, go to Setting -> About -> Software Information -> Build number
  3. Repeatedly tap Build number to put the phone in Developer Mode
  4. Go back to Settings, then to Developer options and enable OEM unlocking. Some sources mention going to Setting -> Power and disabling Fastboot mode.
  5. Power off the device
  6. Power on the device into Download mode by holding Power + Volume down when booting. Older version might call this Fastboot mode (unrelated to above).
  7. Plug phone into PC, you can check if it is connected by typing -- Notice this has to be run as root; I was tripped up by this for an hour. You will just recieve a message "Wating for device..." if this is run as a non-root user.
    sudo fastboot devices
  8. Grab the identifier token
    sudo fastboot oem get_identifier_token
  9. Paste this in the form at
  10. You will receive a file Unlock_code.bin, download it and apply it to the device while it is still in Download mode
    sudo fastboot flash unlocktoken Unlock_code.bin
  11. There will be some promps on the phone. Follow them through.

The phone should now be unlocked. In Download mode, the it should say something like *** UNLOCKED *** at the top.

Install custom recovery image

The next step is to install a custom recovery, TWRP, on the phone. Go to and download the appropriate *.img file. While still in download mode, flash it onto the phone:

sudo fastboot flash recovery twrp.img

Reboot the device.

Install LineageOS

Finally, we can flash the Lineage OS package.

  1. Once you are back in Android, allow file transfers.
  2. Go to and download LineageOS.
  3. Copy this file to the Internal Storage of the phone. (note: if you want Google Apps, jump ahead to that section, download, and copy that package to the Internal storage as well)
  4. Reboot the device back into Download mode.

Now we need to get into our custom recovery. Select Reboot to Bootloader then when on a white screen, Boot to Recovery Mode. This will open TWRP. Swip to allow modification.

First, we need to Factory reset the phone and wipe the Cache. 

  1. Select Wipe
  2. Select Advanced Wipe
  3. Check cache, System, and Data
  4. Swipe to Wipe

Go back to the Main menu and install the *.zip

  1. Select Install
  2. Choose the *.zip
  3. Swith the confirm Flash

After complete, you can choose to install the TWRP app.

Do not reboot into LineageOS yet if you want Google Apps. If you install Google Apps after booting into LineageOS, expect crashes. If you miss this note, you will need redo the wipe procedure, then install).

Install the Google Apps package (optional, but probably not in reality)

Due to licensing restriction, Google Apps (including the play store) cannot be included directly with LineageOS. These havce to be installed manually. Unless you intend to solely side load apps or use an alternate app store (such as Amazon App store). We highly recommend you download the Google Play Store.

  1. Go to Open GApps and download the preferred variant of the Google Apps package. I did ARM64, Android 7.1, and nano.
  2. Plug the phone into the computer and allow file transfers
  3. Copy the *.zip to the Internal storage
  4. Boot into Download mode, then follow the steps above to get into our custom recovery
  5. Click install
  6. Choose the Google Apps *.zip package
  7. Swipe to confirm Flash

Reboot and enjoy!




Contact Us To Setup A Meeting

Feel free to call or email anytime to setup a meeting. We would love to discuss your project to see if we can help!

contact us