Do With Your Own Risk!!
I’ve try this on Nexus 5X on Android 7.1.1 N4F26T Nougat Firmware : bullhead-n4f26t-factory-8eed1d9f.zip, but it should work on any Android Nougat Version
Unlocked Bootloader
Important: do not relock your bootloader unless your phone is fully stock. You must flash the factory images first in order to remove root and custom recovery (if you have them), if this precaution isn’t taken you may end up with a brick. Please see section 10 of this guide for full instructions on how to return to stock.
- Go into Settings/About Phone
- scroll down and click on build number
- continuously until you see a toast notification telling you that you’ve enabled Developer Options.
- Go back to your Settings menu and enter Developer Options
- scroll down and click on the
- Enable OEM Unlock, checkbox,
- also make sure you enable USB Debugging while you’re in the Developer Options menu.
- Power off your phone then boot into the bootloader (power + volume down).
Connect your phone to your PC via usb cable. - Open a command prompt from within your fastboot folder (navigate to where you have fastboot.exe located on your PC, shift + right click anywhere within that folder, select open command prompt here).
- Check your fastboot connection by issuing this command:
fastboot devices
It should return your device serial number, if not you need to make sure your drivers are installed correctly. - Once you’ve confirmed your fastboot connection issue this command:
fastboot oem unlock
This will erase all user data from the device!
You should now see a screen on your phone asking you to confirm this action, use the volume keys to scroll and the power key to confirm if you’re sure you want to go ahead. - Allow the process to complete and then issue this command:
fastboot reboot
Allow everything to go ahead and once finished you can disconnect your usb cable.
Install A Custom Recovery
Do not flash the version of SuperSU that TWRP offers to flash for you in order to give you root, it is not compatible and will cause problems. When you attempt to reboot out of TWRP it will tell you that it’s detecting that you don’t have root and it will offer to root for you, skip past this.
Some users need a custom recovery for a temporary period, so they live boot the recovery. In this scenario, the custom recovery replaces the stock recovery until a reboot is performed. Place the file in your fastboot folder then enter this command:
fastboot boot filename.img
(The recovery filename in the command will change depending on which recovery you’re flashing)
Download TWRP Recovery onto your PC.
Make sure you check the md5 to verify its integrity (where possible).
Place the file in your fastboot folder (this is where fastboot.exe is located on your PC).
Power off your phone then boot into the bootloader (power + volume down).
Open a command prompt from within your fastboot folder (navigate to where you have fastboot.exe located on your PC, shift + right click anywhere within that folder, select open command prompt here), enter this command:
Code:
fastboot flash recovery filename.img
(The recovery filename in the command will change depending on which recovery you’re flashing)
Use the volume keys to scroll and power key to select the Reboot Bootloader option. Once the phone has booted back into the bootloader, use the volume keys to scroll and the power key to boot into your newly flashed recovery. It’s now safe to disconnect your usb cable. If using Nougat 7.0 or newer, you must now boot directly into TWRP and flash SuperSU (or your preferred root alternative) so that TWRP will persist between reboots.
When TWRP boots up you’ll be asked whether you want to allow system modifications or to keep it read-only, choose to allow system modifications, there’s no benefit to keeping it read-only.
Root
Download SuperSU-v2.79-201612051815.zip
Prerequisites:
- unlocked bootloader (section 1)
- TWRP recovery (section 2).
- Download the latest SuperSU of your choosing to your phone:
- Boot into TWRP recovery and enter the install menu.
- Navigate to where you have SuperSU stored on your internal storage and select it.
- Swipe to install.
- Once you’ve installed SuperSU you’ll have an option to wipe cache/dalvik and an option to reboot system.
- Wipe the cache/dalvik, hit the back button, and hit the reboot system button. That’s it.