I'm happy to share with you an updated guide on how to root the Xperia XA.
This guide is Only for Nougat (Android 7.0), for Marshmallow (Android 6.0) it's here: https://forum.xda-developers.com/xpe...2#post67988142
## How to root the Sony Xperia XA
The Sony Xperia XA is a midrange smartphone with a bezeless design. It has adequate specs and run Android aptly. These aspects make this phone a great daily driver, however the Sony stock Android is plagued with trashware and all the hurdles Android itself has several privacy problems.
By rooting the phone one can circumvent these limitations. You will be able to install the Xposed framework, improve sound with Viper4Android, block hosts, install dns-crypt and improve overall customability. In the follwing sections I will present the steps to root your phone.
But before proceeding a word of caution (or why you wouldn't like to root your phone):
1. Unlocking your BootLoader will void your warranty, break your device DRM and lose X-Reality and image optimisation on low light when taking pictures.
2. You can save your DRM keys (TA backup) by following this guide: http://forum.xda-developers.com/cros...ackup-t3514236. You have to do it BEFORE unlocking the bootloader, fro this you need to downgrade to an old Marshmallow firmware, for now you can't root AND restore your backup.
3. You can re-lock your phone and it will restore DRM if you have a backup but you lose root and recovery.
4. Unlocking your bootloader will wipe the device (factory reset)
5. If you have confidential files in your phone don't unlock your bootloader, as long as your phone is locked your data are officially secured.
6. Make a full backup of your personnal data before following this guide.
1. Find out whether if you bootloader can be unlocked, which is needed to proceed. Type: *#*#7378423#*#* then choose Service info ---> Configuration ---> Check for "Bootloader unlock allowed: Yes". At this point if the phone has No or any other answer at the screen you shouldn't porceed as rooting will be impossible.
2. Download XA ADB and Fastboot drivers: https://developer.sonymobile.com/downloads/drivers/
3. Download FLASHTOOL with integrated Xperifirm 0.9.23.2 for Windows, note that you can also use it to unlock your
bootloader(http://www.flashtool.net/downloads_windows.php) DON'T USE AN OLDER VERSION OF FLASHTOOL AND DOWNLOAD FIRMWARES FROM THE
4. Follow the official Sony instructions for getting the unlock code from [here](https://developer.sonymobile.com/unlockbootloader/). Further paste the code in BLU menu of Flashtool. You can also find video instructions [here](https://www.youtube.com/watch?v=6lKWd5LlUoA).
5. Download the proper files for your phone version/variant:
Magisk Manager apk package: http://www.apkmirror.com/apk/topjohnwu/magisk-manager/
For XA single sim = F3111, F3113, F3115
TWRP recovery: https://forum.xda-developers.com/xpe...ry-xa-t3639206
For XA dual sim = F3112,F3116
TWRP recovery: https://forum.xda-developers.com/xpe...l-sim-t3638725
6. Power off the phone and flash ONLY "BOOT_DELIVERY" from a Marshmallow firmware with Flashtool ( exclude all other patitions), you must only see
"boot_delivery.xml" in the "Content" column.
7. Power off the phone again and enter the phone in Fastboot mode (when power off, hold Vol+ and plug the phone). The led should be blue.
8. Copy the downloaded boot and recovery to "C:\Flashtool\x10flasher_lib" and rename them to boot.img and recovery.img, if you computer is not set to show file extentions remane them
without .img at the end
9. Flash recovery and boot with "fastboot flash boot boot.img" and "fastboot flash recovery recovery.img" commands and then delete them.
10. Unplug the phone, hold "Vol-" and "Power" buttons. Release all buttons after phone vibrate.
11. You are in TWRP recovery, on password prompt press "Cancel"
12. On next screen press "Swipe to allow".
13. Format "userdata" partition to remove internal encrytion for restoring TWRP backups/acces of /data partition, go to "wipe" and tap "format data". If you don't this your phone will
bootloop on Xperia logo. Don't forget to backup your personnal data before !!
14. Reboot to Android (it will takes about 10 minutes) and follow instructions until you are on the Home screen.
15. Install Magisk Manager apk package from the given link, you have to enable "Unknown sources" in the security menu before.
16. Open Magisk Manager and tap "Download" at the bottom, wait until you see download complete and reboot to recovery.
17. Go to "Install" and select "Magisk-vX.XX.zip" located in /sdcard/magisk manager, swipe to intall.
18. Power off the phone again and repeat step 6 with your actual Nougat firmware or the phone will not detect Sim Card(s)
19. Reboot the phone.
20. Tap the "Thanks! " button at the bottom right of this post, optionally you can offer me a coffee/beer/tea or energy drink to support my work, my PayPal adress is in my profil.
21. Your phone is rooted
After these steps your phone should be rooted and you will be able to have root access to the system. This tutorial comes with no garanties that it will work and the author does not take any responsibility for you bricking your device. Also, installing third party files are a security liability, you should be aware of that. If you don't follow exactly the guide you will probably brick your phone.
Despite these issues, rooting the Xperia XA has been confirmed to work on Single and Dual Sim.