Root Sony Xperia XZ2/Compact/Premium Android 10 using TWRP and Magisk

In terms of software support, Sony is decent compare with other mobile manufacturers. They always roll out minor security patch updates and significant upgrades frequently. The problem is a considerable upgrade most of the time comes as a bug OS. They have to roll out again the patch updates for Major OS. Also, They don’t utilize the hardware as other companies do. But when you are a regular user who uses your mobile for dealing with regular apps, Sony Xperia XZ2 can give better performance. So, You don’t need to root your mobile to adjust the settings manually. But When you are a regular Root apps user or Custom ROM user, You can Root your Sony Xperia XZ2 Android 10 version using the below method. The Root method works with TWRP. SO, You can uninstall custom ROMs if you need it.
Sony Xperia XZ2 and XZ2 Compact on the Table

Read the article thoroughly before starting the process. It will give some ideas for the preparation. If you planned to flash Custom ROMs, you should check what will work and whatnot. Unofficial ROMs may contain a lot of significant bugs. If you want to install the update using TWRP, after the firmware flash, you should flash Magisk every time.

Should you Root Sony Xperia XZ2/Compact/Premium on the Android 10 version?

We thank XDA Developer- topjohnwu and MartinX3 (Who successfully tested this method) Without their hard work, We can’t make this method. Coming to root, you should have a proper reason, and you know what you are doing. Yes, with a minimum of 4/6 GB RAM and Qualcomm Snapdragon 845 processor, You can use this mobile for regular tasks without root for 2-3 Years If you use correctly. Android 10 Software is better compared with other manufacturers, Custom skin OS. Don’t root because everybody is saying when root your mobile it can become fastest. No. Rooting is to extract some performance from the device. But, you already have Powerful specs and software. So, If you are addicted to some root apps, you can root. But, if you want to test, I won’t recommend it.

Also Read-  Sony PlayStation Spartacus Game Pass may Stars from $10/Month

How to Root Sony Xperia XZ2/Compact/Premium Android 10?

Sony Xperia XZ2 International Variants comes with a flexible bootloader other than some carrier locked devices. It means that different smartphone variants can be easily rooted. Also, the device can accept to install TWRP recovery or any other custom recovery file/app alike.

TWRP recovery is a custom recovery file that must be installed on your devices because you can root them successfully. In this article, we explained the easiest method to follow and install TWRP recovery on Sony Xperia XZ2. However, the tool required for rooting this device is the Magisk App.

With the help of TWRP Recovery, you can quickly flash the latest version of Magisk into your Xperia XZ2 to gain root access. Before sharing the tutorial, you may want to know that, with the TWRP recovery present on your device, you can easily install any custom ROM or firmware. Does it seem complicated? Relax, everything will be explained succinctly in bullets.

Samsung Galaxy S23 Renders
Samsung Galaxy S23 Renders

Things to check out for;

  • Make sure your device battery is above 50%.

  • Full data loss process. So, Backup your current files and data (save them on external storage).

Supporting versions

Xperia XZ2
  • H8216
  • H8266 Dual
  • H8276
  • H8296 Dual
XZ2 Compact
  • H8314
  • H8324 Dual
XZ2 Premium
  • H8116
  • H8166 Dual

1. Download Necessary FilesOnePlus 6T OEM Unlock and USB Debugging

  • Enable USB Debugging Mode and OEM Unlock on your mobile. To do this; go to settings >>> about >>> Tap on the “Build Number” 7-10 times consistently to enable “Developer Options,” then go to the “Developer Options” and enable USB Debugging Mode, OEM Unlock. There is no complicated process in Sony Xperia XZ2.

  • Camera Fix (Optional) Download and Copy it to Your mobile SD Card. This file helps you to maintain the bootloader unlock and debug some Root issues in your device.
  • Download, extract, and save the TWRP File in your PC and your External mobile storage and rename it to recovery.img. You should keep the file in both locations.

  • Based on your model number, Download, extract and save the VB meta Files in your PC and rename it to vbmeta.img.
  • Copy all the above files into the Fastboot folder.

2. Unlock Sony Xperia XZ2 bootloader using ADB and Fastboot

Your mobile should be supported to get the unlock code. Check this using the below step. If your mobile supported, get the code and unlock using unlock stages.

Also Read-  Install Sony Xperia XA2/Ultra Lineage OS 16.0 Android Pie 9.0 Official ROM

2.1 Check Compatibility

  • Go to Sony Developers Official Page to check if your device model is available in the list.
  • You should signup to a new Sony Xperia account or login with details to an existing account. Alternatively, you can use your Gmail account.

  • The device should have an internet connection.

  • Dual SIM Sony devices have two IMEI numbers. Use the IMEI 1 to get the exact unlock code for your device sony

  • This action works for all Sony Android devices. However, you still have to check out if your device model supports such action (unlocking the bootloader);

If your device is supported, then go ahead with the steps below to unlock the boot loader.

2.2 Unlock Steps

  • Open your phone dialer and dial this code – *#*#7378423#*#*

  • Go to Service Info >>> configuration >>> rooting status >>> Check to see if bootloader unlocking is allowed or not. If it is allowed, then continue below.

  • Get the “” file and paste it into the folder where you installed ADB and Fastboot.

  • Dial *#06# and copy down your Sony Mobile IMEI number.

fill details to get unlock ID sony

  • Return to the Sony Official page, select your device model, and provide your Email Id.

  • You will receive a link to your Email id, click on the link to get the Unlock code to use and unlock your bootloader.

  • Switch off your device. Then, enter into Fastboot mode. To do this, press and hold down the Volume Down button connect mobile to your PC using USB Cable.
  • Go to the ADB and Fastboot folder, Launch the fastboot on your computer. Open a Command prompt on your PC and type below command.

  • fastboot devices
  • It should display the connected devices. If you didn’t get the mobile, restart the command prompt and Disconnect and Connect your Sony Xperia XZ2 if you are detected type below command and Hit Enter.
  • fastboot oem unlock 0x<insert your unlock code>

Note: you have to replace the key with your own generated key

  • Tap “Enter” and wait for some time

  • Your mobile bootloader is now unlocked, reboot the device. Move to flash TWRP steps.

3. Flash TWRP in Sony Xperia XZ2 Android 10 devices

Xperia XZ2 Download Mode

  • Switch off your device. Then, enter into Fastboot mode. To do this, press and hold down the Volume Down button connect mobile to your PC using USB Cable.
  • Launch the fastboot on your computer. Open a Command prompt on your PC and type below command.

  • fastboot devices
  • It should display the connected devices. If you didn’t get the mobile, restart the command prompt and Disconnect and Connect your Sony Xperia XZ2 if you are detected type below command and Hit Enter.
  • fastboot –disable-verity –disable-verification flash vbmeta vbmeta.img
  • After the flash of the above file, type below command and hit Enter.
Also Read-  Root Motorola Moto G82 5G Android 12 using Magisk XT-2225

fastboot boot recovery

  • fastboot boot recovery.img
  • If you can’t reboot your mobile using the above command, Press Volume Down+ Power button to exit Fastboot mode. When the screen goes off, Immediately Press Volume Up + Power buttons to boot into Recovery mode.
  • It will boot into the temporary TWRP. Don’t Boot into standard OS until we flash magisk.

4. Install TWRP and Magisk in your Sony Xperia XZ2 using TWRP

  • In TWRP, Make a full Backup on External SD Card or Pendrive using OTG Cable.
  • After the process complete, Reboot to Bootloader using TWRP Option. Reboot->Reboot Bootloader.
  • Go to TWRP menu. Select Advanced Menu->Install recovery ramdisk->recovery.img.
  • Go to the TWRP menu. Select Wipe->Advance Wipe->Select Cache Data. The same process goes for the VB Meta.img file.
  • Return to Home of TWRP select Install.
  • Select Magisk.Zip.
  • Again Return to Home of TWRP select Install.
  • Select the Camera Fix.Zip. Don’t use Add more Zips in TWRP. Install one by one.
  • After the Installation Reboot Your Mobile.

What More?

In my opinion, you don’t need rooting for your Sony Xperia XZ2. If you thought you could Improve Performance By root; With the Qualcomm Snapdragon 845 Octa-Core processor and 4/6 GB RAM, your device can perform well. If you don’t know how much RAM you need, You will never use this much RAM. Don’t Install any apps other than trusted sites on rooted devices. Third-party site apps can contain some background codes. So, Check twice before installing those apps. If you want to return to stock firmware, flash Sony Xperia XZ2 Android 10 firmware. During this process, If you face any problem, comment below.

Source, (2)

Share This Post:

8 thoughts on “Root Sony Xperia XZ2/Compact/Premium Android 10 using TWRP and Magisk

  1. Hi.
    I have my Sony Xperia XZ2 Compact SO-05K (NTT DoCoMo Japan, Android 10) stuck on the Sony Logo after trying to install LineageOS 17.1: –> “No space left on device – No such device.”
    I tried ‘Root Sony Xperia XZ2 / Compact’ here, following the tutorial, but in “fastboot flash recovery recovery.img” -> failed writing recovery “FAILED (remote: ‘no such partition’).
    How do I solve this problem?
    That said, I am not an expert.
    I would very much appreciate your help. Thanks.
    Antonio leal

  2. SALVE!
    Possiedo un telefono “Xperia XZ2 H8216” ho provato a fare esattamente come scritto nella procedura del bootloader e con esito positivo!
    Però mi sono accorto che ogni volta che accendo il dispositivo, mi appena una immagine di un lucchetto aperto con delle scritte in inglese!
    Se potessi metterei l’immagine qui, ma non si può fare purtroppo.
    Cosa devo fare, dove ho sbagliato secondo voi???
    Se potete aiutarmi ne sarei felice, grazie.

  3. Hi, do I lose some functions if I unlock the bootloader, like camera and sound? Is it possible to go back stock completely?
    And is it google camera fully supported on xz2c? Is it worth doing it just for the camera?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.