Make sure you don't have ANY data you want to keep on your phone before following these or any other instructions. Bear in mind that although the phone was rooted successfully, the default Sony camera app isn't currently working, and there may be other problems I haven't found yet.
Wanted to put together a quick guide for how I rooted my Sony Xperia Z5, as I ran into a fair few difficulties that aren't mentioned on any of the standard XDA-Developers posts.
First off, I had to get access to the Developer Options menu. This is pretty easy - all I had to do was go to Settings -> About Phone and tap
Build a bunch of times. When I went back into the root Settings menu, a Developer Options menu had appeared.
Next, I started following the instructions on Sony's website. I installed the linked Android SDK without too much trouble, although I did have to install Java 1.7 before continuing. I also had to retry installing the SDK, as I had an Explorer window open which seemed to interfere with the process -- overall, there wasn't any great difficulty. I opened up the Standalone SDK Manager and installed Google's USB drivers, as Sony suggested might be necessary.
The first major problem I ran into was with the USB drivers. I followed the instructions for fastbooting my device, holding the volume-up key while I plugged the USB cable into the device. Unfortunately, when I then tried to run
fastboot devices, I got no output: no errors, no devices, nothing. The same happened with
adb devices, as I saw suggested on a few StackExchange posts.
The problem, as it turned out, was with an instruction I thought I could skip: Sony's instructions mentioned that Windows users would have to choose the driver manually, but my Windows 10 machine seemed to install everything automatically. The problem was that
fastboot devices wasn't giving me any results, even despite my phone showing a black screen and blue light.
I followed the advice of a SE commenter and went to Device Manager to manually select the drivers used. Here was where it started to get worrying: when I right-clicked the device ("S1 Fast Boot") and navigated to the new driver I'd just downloaded, I got an error message to the effect that Windows had found my driver, but wasn't going to use it because it couldn't find a verification hash.
With a bit of Googling and common sense, I worked out that the problem involved newer versions of Windows refusing to install unsigned drivers by default. Once I'd found this, it was pretty trivial to find out how to disable this security feature: although the first method I found - typing a
bgedit command into an administrative command prompt - didn't work, the second did: navigating to settings->advanced settings->reboot and choosing the option to disable driver signing with the F7 key.
So that was it: after the reboot above,
fastboot successfully found my phone. It's worth noting that I'd previously followed Sony's instructions to actually connect the phone in fastboot mode: hold the 'volume down' button while connecting the USB cable.
The next steps were to flash both a recovery image and an insecure kernel. For the insecure kernel, I used the command from point 7 here verbatim, and for the recovery image I chose something more like the manual flash command here.
I would have continued with the androiding.how guide in order to flash the SuperSU binaries, but unfortunately I ran into a major problem:
adb devices wasn't returning anything. I spent some time searching for the issue in vain, and then (at the point of giving up) had a closer look at the actual commands. All the guide was really doing via ADB was mounting a couple of directories and pushing the ZIP file - both of which I could see TWRP had options to do right on the device. I made sure
/system was mounted (basically mounted everything I could see in an attempt to compensate for the fact that I couldn't see a
/userdata directory), and installed the zip right off the internal storage. Luckily for me, it worked flawlessly!
Just to check everything was fine and dandy, I downloaded Root Checker from the Play Store, and it came up positive after confirming that it was allowed root permissions.
And later, I found that the camera app crashed after every startup. More on that when I work out how to fix it.