Flashing a custom ROM is part of why most users root their phones in the first place, after rooting your phone you can choose to customize your stock firmware by using Xposed Framework, which are great unless you want to fully customize (or replace) your experience, for that you will need custom ROMs. A Custom ROM is a modified version of the Android operating system. Tweaks, additional features, theme engines and an enhanced performance can be achieved.
Before you continue with the steps listed in this guide; you acknowledge and accept that any damage to your phone caused by your attempts to root your phone is your own responsibility. Appuals, the (author) and our affiliates will not be responsible for a bricked device, dead SD Card, or anything to do with your phone. If you don’t know what you’re doing; please research and If you do not feel comfortable with the steps, then DO NOT PROCEED.
Note that Cyanogenmod 12.1 is a NIGHTLY version, meaning it could be less stable than your official ROM, it can have different bugs in different system aspects but the developers work on it every day to achieve perfection, if you do not want to handle bugs I advise you not to flash this ROM, also if you decide to go through with this article, please check the Cyanogen mod downloads website every now and then as Nightly versions tend to be updated daily with bug fixes and stability improvements.
A laptop with internet access and a USB port.
Your phone well charged and a USB cable
Stage 1: Backup and Unlocking the bootloader
Before unlocking the bootloader you are going to want to have a backup of your DRM keys which the manufacturer uses to check warranty, this means that you will lose your warranty but do not worry you can always re flash your backup whenever you need your warranty. Connect your phone to your laptop using the USB Cable , Download the backup software from here and extract it. Run the .exe file (should be named Backup-TA) and select one to backup, make sure that the ta.img is in C:\ Backup-TA \ tools \ backup , once done backup all data that you might need further like photos, music, contacts and any other data as you will lose them in the process.
When done with the backup download this Flash tool here and install in where you can easily access it, after the installation is complete you will find a Flashtool.exe file, run it and You will see a BLUE icon, then the application will ask you to put your phone in flash mode, this can be done by turning off your Xperia Z -> then reboot the phone and Press and Hold Volume Down button whilst holding it, connect your phone to your laptop using the USB Cable. Next, in the flash tool device menu choose ‘Sony Xperia Z’. click on ‘Unlock’and start the process, when the unlocking is done you will see a flash tool log file.
Stage 2: Flashing a Custom Recovery
Now we are going to need to flash a recovery for your device and we will choose TWRP recovery for the job. Please first ensure that the adb debugging in your phone is turned on , on your phone go to Settings -> About Phone and tap on Build number until a message saying ‘ you are a developer is presented’ then press return and open ‘Developer options’ and enable ADB debugging (or USB debugging).
The flashing will be done by ADB, adb acts like a bridge between your phone and your PC that enables you to flash recoveries, side load applications and many others. Firstly download android sdk by clicking here, which will be used to connect and send commands to your phone. After being downloaded, extract the file and run the .exe file you should see, it should be named Android SDK Tool Setup (exe). Once done, download the SDK Manager, by double clicking on the SDK Manager from the SDK Folder. When it asks what packages do you want to download search for platform tools, tick the option and untick everything else, press “install this package”. Once the package is installed go to the platform tools folder and copy cmd file to this folder (which is located in c:\windows\system32). Connect your phone to your laptop first to ensure it gets detected. If your phone does not get detected please download its drivers from here. When done, using your phone, download the TWRP image from here and place it into your SD card folder (If you are reading this on your laptop you can download it using your laptop and copy it to the SD card folder on your phone). Once done open the cmd file you copied into your platform folder and open it. Type in ‘adb devices’ to ensure your device is read.
After that type in this ‘dd if=/sdcard/twrp.img of=/dev/block/platform/msm_sdcc.1/by-name/FOTAKernel’ (without quotation marks)
Stage 3: Flashing Cyanogenmod 12.1 ROM
And wait for the flashing process to be completed, once done reboot your phone and it should have the custom recovery. Now for flashing the Rom part. Using your phone Download the latest Cyanogen mod build from here and after that download the Google applications from here, Make sure you choose ARM and android 5.1, choose mini or micro based on your needs. Make sure you place them in a folder that you can easily find, like the SD card folder for example.
When downloaded turn off your phone and get into recovery mode by turning it back on and when it vibrates press and hold both Volume up and down until it boots into TWRP, when booted press on “wipe, then advanced wipe and mark on Dalvik Cache, Cache, System and Data. Then swipe to complete the process.
When done press return and press on Install and then browse to the Cyanogen mod ROM you downloaded earlier and press on it and flash it. Repeat the same process with the Google apps you installed and your phone should be ready.
When done reboot your phone, it should take some time at first to initialize but after that you should have Cyanogen Mod 12.1 on your phone! Start customizing!