ThisCalculator

Everyday

Unlock & Root Sony Xperia XA2: Step-by-Step

Updated · Standard formula, shown below

Unlock & Root Sony Xperia XA2: Step-by-Step

Unlocking the bootloader and rooting your Sony Xperia XA2 gives you full administrative control over the device. This lets you remove pre-installed bloatware, install custom ROMs, use root-only apps, and tweak system settings that are normally locked down. This guide walks you through the entire process, from backing up your data to verifying root access, using official Sony tools and the widely used Magisk method.

What You’ll Need

  • A Sony Xperia XA2 (model H3113, H3123, H3133, H4113, or H4133) with the bootloader unlockable.
  • A Windows PC (or a Mac/Linux with ADB and Fastboot installed).
  • A USB cable that supports data transfer.
  • Your Sony Xperia XA2’s IMEI number (dial *#06# to see it).
  • The Sony official bootloader unlock code (obtained from Sony’s developer site).
  • The latest Sony USB drivers for your XA2.
  • ADB and Fastboot tools installed on your PC.
  • The Magisk APK (or the Magisk ZIP for flashing via custom recovery).
  • A stock boot image for your exact XA2 build number (you can extract it from the official firmware using a tool like Sony’s Flashtool or from a stock ROM ZIP).

Step-by-Step

  1. Back up everything. Unlocking the bootloader wipes your phone completely. Copy photos, videos, contacts, and any other important files to your PC or cloud storage. Make sure your Google account sync is up to date.
  2. Enable Developer Options and USB debugging. Go to Settings > About phone and tap Build number seven times. Then go to Settings > Developer options and enable USB debugging and OEM unlocking.
  3. Get your bootloader unlock code. Visit Sony’s official bootloader unlock page (developer.sony.com/develop/open-devices/get-started/unlock-bootloader). Sign in with your Google account, enter your XA2’s IMEI, and you’ll receive an unlock code by email. Save it.
  4. Install ADB and Fastboot on your PC. Download the platform-tools from Google’s developer site and extract them to a folder (e.g., C:\adb). Add this folder to your system PATH or open a command prompt inside that folder.
  5. Install Sony USB drivers. Download and install the latest Sony USB drivers from Sony’s support site. This ensures your PC recognizes the phone in fastboot mode.
  6. Boot your XA2 into fastboot mode. Power off the phone. Then press and hold the Volume Up button while connecting the USB cable to your PC. The LED should turn blue, indicating fastboot mode.
  7. Verify fastboot connection. In your command prompt, type fastboot devices. You should see your device listed. If not, reinstall drivers or try a different USB port.
  8. Unlock the bootloader. Type fastboot oem unlock 0x<your_unlock_code> (replace with the code you received). Confirm any on-screen prompts. This will wipe your phone and reboot. After it reboots, go through the initial setup again, and re-enable USB debugging and OEM unlocking in Developer options.
  9. Re-enter fastboot mode. Power off the phone, then press and hold Volume Up and connect the USB cable again. The blue LED should appear.
  10. Extract the stock boot image. Download the stock firmware for your exact build number (you can find it on XDA or via Sony’s update service). Use a tool like Flashtool or a ZIP extractor to get the boot.img file. Place it in your ADB folder.
  11. Patch the boot image with Magisk. Transfer the boot.img to your phone’s internal storage. Install the Magisk APK on your phone. Open Magisk, tap Install > Install again > Select and Patch a File, and choose the boot.img. Magisk will create a patched file in Download (usually named magisk_patched-*.img).
  12. Copy the patched boot image to your PC. Transfer the patched file from your phone’s Download folder to your ADB folder on your PC.
  13. Flash the patched boot image. With your phone in fastboot mode, type fastboot flash boot magisk_patched-*.img (replace with the actual filename). Wait for it to complete.
  14. Reboot your phone. Type fastboot reboot. Your phone will boot normally.
  15. Verify root access. Open the Magisk app. It should show Installed with the Magisk version. You can also use a root checker app from the Play Store to confirm.

Common Mistakes

  • Wrong boot image. Using a boot image from a different build number or model will cause boot loops. Always match the exact firmware version.
  • Skipping the backup. Unlocking the bootloader erases all data. Forgetting to back up is the most common and painful mistake.
  • Not enabling OEM unlocking. If you skip this step, the fastboot unlock command will fail.
  • Using a faulty USB cable. Some cables only charge and don’t transfer data, causing fastboot to not recognize the device.
  • Incorrect fastboot commands. Typing the unlock code wrong or missing the 0x prefix will fail.

Tips

  • Keep your bootloader unlock code in a safe place; you’ll need it if you ever relock the bootloader.
  • After rooting, install a custom recovery like TWRP to make full backups and flash ZIPs more easily.
  • Use Magisk’s built-in module repository to add features without modifying system files.
  • If you encounter boot loops, you can always reflash the stock boot image via fastboot to restore normal boot.
  • Always use the latest Magisk version to avoid compatibility issues with Android security patches.

Troubleshooting

  • Fastboot doesn’t detect the device. Reinstall USB drivers, try a different USB port, and ensure you’re in fastboot mode (blue LED). On Windows, check Device Manager for any unrecognized devices.
  • Unlock command fails with “unknown command”. Make sure you’re using the correct fastboot syntax and that your device is in fastboot mode, not ADB mode. Also, ensure you’ve enabled OEM unlocking.
  • Phone boots into a boot loop after flashing the patched boot image. This usually means the boot image was for a different build. Reflash the original stock boot image to get back to normal, then re-patch with the correct file.
  • Magisk app shows “Requires Additional Setup” or “Ramdisk Missing”. This can happen if the boot image wasn’t patched correctly. Re-patch the boot image and flash again.
  • Root checker says not rooted. Verify that Magisk is installed and shows the correct version. If not, reflash the patched boot image.
  • Wi-Fi or cellular issues after rooting. This is rare but can happen. Try reflashing the stock boot image first; if that doesn’t help, you may need to flash the full stock firmware and start over.

Frequently Asked Questions

Does unlocking the bootloader void my warranty?

Yes, in most regions, unlocking the bootloader voids the manufacturer warranty. Sony’s official unlock process also states this.

Will I lose my data?

Yes, unlocking the bootloader wipes all data. You must back up before starting.

Can I relock the bootloader after rooting?

Yes, but it’s risky. You must restore the stock boot image and all system partitions first, then use the command fastboot oem lock 0x<unlock_code>. Relocking with root or custom software can brick the device.

What is Magisk?

Magisk is a systemless root solution that allows you to root without modifying the system partition. This makes it easier to pass SafetyNet and receive OTA updates.

Will I still get OTA updates after rooting?

Generally, no. OTA updates will fail because the system has been modified. You’ll need to manually flash updates or use custom ROMs.

Is rooting safe?

Rooting itself is safe if you follow the steps correctly. The risk comes from flashing wrong files or making system changes that can cause instability. Always back up and follow guides carefully.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.