yashsingh1/xdaforums huggingface dataset:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] BananaJoh:
Ah thx, ok ... so updating to 20.0 is no problem.

Just to sum up the nanodroid install steps for those who are interested (AOSP Android 9 with Magisk already installed):

1.) deodex services.jar using vdexExtractor and compact_dex_converter (as described in the official NanoDroid GitLab repo and the vdexExtractor GitHub repo)

2.) install nanodroid-patcher to enable signature spoofing support (if not already built-in)

3.) create configuration files for setup and install nanodroid

4.) install EdXposed (Riru-EdXposed [I chose the SandHook version] and its dependency Riru-Core) via Magisk as well as EdXposed Manager via APK from GitHub

5.) install FakeGApps via EdXposed Manager

6.) have fun :D

EDIT: I inserted step 4 and 5 as it was necessary for me to get the checkboxes "System spoofs signature", "Play Services (GmsCore) has correct signature" and "Play Store (Phonesky) has correct signature" in microG self-check. After doing this, step 6 evaluates to true now as apps that missed the Play Services before don't complain anymore ;)

Source (I hope this kind of link is ok): https://www.reddit.com/r/MicroG/comments/asnom5/apps_wont_run_without_google_play_services_which/
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Anti-root:
XZ2C Root

I realized that many users are confused, as I was, because of many conflicting or/and incomplete reports on the procedures of rooting. Nobody's fault, of course, since so many cases are different and unique. For what it is worth, this is what I did:

XZ2C with '32 firmware -

1. Unlock bootloader (if Sony allows)

Boot into fastboot

2. fastboot devices (to see if your device is recognised)

2. fastboot reboot bootloader

3. fastboot flash vbmeta vbmeta.img

4. fastboot boot twrp.img

5. fastboot reboot recovery

From TWPR

6. Install (flash or however you want to call it) magisk.zip

7. Wipe->Advanced Wipe -> Choose Cache Data

8. Reboot into system

9. Install "Magisk Manager.apk", even if it says it is present!

This is root with standard Sony ROM. You can debloat, install your root apps etc.

For me, it is enough for now.

Use the proper recovery file from the link in the first page

. Do not forget to thank the developer. It is they who do all the hard work, from which we benefit.

Thank you! :good:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] DUMIY:
Does rooting stock Sony rom affects camera (loosing quality) or breaks any other things? Thanks!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] BENETNATH:
i don't think so.

The only step that would have an impact on the photo quality is unlocking the bootloader
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
I didn't saw a photo quality affection on my xz2
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nreuge:
It does. Zoom in a low light photo and you will the difference, denoising is much less good. It's a pity that I don't have kept my photos comparisons...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Then lets see how far the camera updates in the SODP based ROMs going.

The Sony employee said that with the new Qualcomm CamX camera framework we will have much potential which will get implemented over the time.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] bobbywan30:
put a video please. for beginners like me please video root xz2

put a video please. for beginners like me

please video root xz2
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] DUMIY:
Thank you for clarification. Honestly that's the only thing keeping me from rooting, as much as I wold like to.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] zhka:
Mhm... I don't see any difference too.

https://drive.google.com/drive/folders/1-zBTIe3cPRREki2znynm8eHnzE5MLJOQ

Or mb you'll show me bad denoising at work from those photos?

P.S. it's not auto > manual mode.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] shibUyA-:
I flash latest stock firmware by newflasher，but I can't use adb reboot into bootloader. And adb show < waiting for any device >, but I I installed the latest driver.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] dhacke:
Is usb debugging in the developer options activated?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] shibUyA-:
thks bro. you reminded me that I can use the adb directly in the system instead of entering the bootloader in fastboot:)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Or just "fastboot reboot bootloader" [emoji14]
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] JohnBay:
Stuffed up...

I need a bit of assistance please...

I managed to flash Magisk Manager in the first step of the guide on page 1.

In other words, after doing 'fastboot boot twrp.img' I did an advanced wipe and then the Magisk flash.

Now the phone boot loops and while I can enter fastboot and from there TWRP, the 'install recovery ramdisk' leads to TWRP being stuck on its logo on reboot to recovery.

I don't see a way now to remove Magisk and restore the original boot.img - trying to run the uninstaller produces an error.

What to do?

I know Magisk normally does a backup of the original boot.img but how to restore it without being able to get into TWRP proper?

The phone is the single SIM version of XZ2 Compact and has been upgraded to the latest firmware before I attempted to root it.

Thank you.

---------- Post added at 04:43 AM ---------- Previous post was at 03:49 AM ----------

To add to my post above:

I tried to flash MartinX's AOSP 9.0 ROM via fastboot.

No errors during the process.

Booting into TWRP from fastboot allowed me to install TWRP into ramdisk.

From there I was able to remove Magisk - or so it appeared.

Now the phone is stuck on Sony logo.

So I flashed the AOSP files again, via fastboot.

Now I get a red triangle with a message: 'Your device is corrupt and will not boot. Power off in 5 seconds.'

Then it powers off.

Is there any way how to load a factory image to get it back to original?

I can get access to a Windows computer if it is necessary to use a Windows-only program for this.

Thank you.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] orapyt:
You can restore back to original firmware on Linux or Windows. It is up to you.

Make sure you have the following:

adb/fastboot (through package manager for Linux ('android-tools') or here for Windows)

mono (required only for Linux, through package manager)

Drivers (only required for Windows--install them from device manager when you have device turned on normally, and then again after you reboot into bootloader, as Windows detects it as a different device)

XperiaFirm

Newflasher

Then just follow these steps:

Use XperiaFirm to get latest stock firmware with your customization (run with mono on Linux)

Delete userdata{somethingsomething}.sin from the firmware folder created by XperiaFirm (deleting this will keep your userdata, but maybe its corrupt so you might not want to delete this)

Place Newflasher into the folder

Shut-off phone

Hold volume-down button and plug in phone to computer to enter recovery mode

Run Newflasher and enter 'n' when prompted

Just wait until everything finishes
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
And you can use ADB at the TWRP logo screen to pull or push files from or to the device with root rights.

I sadly can't reproduce your issue

Following the instructions on the first page everything works here
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] JohnBay:
Thank you both, gentlemen.

I had no luck with Flashtool, both Win/Linux versions. Even when it managed to finish the process, the phone would display a "Your device is corrupted & not safe and will not boot" message.

However the Sony Emma tool managed to restore the device and on another attempt I've managed to install TWRP and Magisk.

Thanks again!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] orapyt:
Weird. Did you try Newflasher (not Flashtool) before trying Sony Emma tool? Also, if possible, try to save the output next time you use it and it fails...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] JohnBay:
No, sorry. I just went with the Androxyde Flashtool. I tried the most recent version (0.9.28) and one I had from an older Xperia phone, running Android 7.1 (version 0.9.24).

The phone was detected correctly in both bootloader and flash mode, and I also used an updated flash script for the device. The current Flashtool would just stall on the initial step ' Sending getvar:max-download-size'

The older version goes past that but then stalls at 'Sending sync'.

Never mind, the main thing is that the phone is now back to working status. I guess sometimes it can be a bit of a hit and miss as to what works and what does not.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Pandemic:
Try newflasher then.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Auggystyle:
Maybe a stupid question, but what kind of data will be lost being unable to decrypt the userdata? I've been waiting forever to root this phone, but it just seems like every new sony device I get, gets more and more complicated to root. I've gone from the TL to the X performance and on to the xz2 compact and every time I go to root, sony has thrown more and more curve balls. Thanks.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Klaus N.:
Being unable to decrypt the userdata partition is only meant to TWRP - when you've booted into system, they're decrypted, ofc ;)

Means, you won't lose anything of your data. You only can't read it (the userdata partition of the internal sd card while booted into twrp [you only will see hieroglyphics there]) atm. But it will work again in the future, I'm sure; you just have to be patient. As a workaround, simply place the files you want to

- copy to your pc or

- flash via twrp

etc

to your external sd card (which isn't encrypted), and it will work :good:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nico_dh:
Hello Martin and all, I'm having a little issue. I managed to make twrp work at the beginning in 8.0then went to 9.0 firmware, lost the camera preview,, ent back to 8 and got the camera back.

Since then (did this a couple of times) I cannot get twrp to work, when I try to go into recovey, hardware or using adb/fastboot, the phone reboots into system, just before that there is a small green led blink.

That is all. What can I try?

Thanks s
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Please install twrp or stay with fastboot boot twrp
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nico_dh:
I tried fastboot boot but does not enter twrp.

I also tried fastboot flash recovery twrp. Img

Same result.

I even got into the android recovery at one point (don't k ow how to reproduce it but got there twice)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
sounds like you're using the incompatible 4.14 10.0 build
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Genesizz257:
Deleted.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nico_dh:
I made a screens hot of what I have.

I can't show it now but my build is 51.1.a. 11.51

And kernel is 4.9. 6.5 perf+

I used newflasher with the files you shared (at least this is what I believe)

Thanks for your help.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Does it work on this older stock rom?

You still have a TWRP matching this version?

Did you try it with the newest .32 stock firmware?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nico_dh:
Well I thought I downloaded from your link, maybe I'm wrong and in that case this is the issue. I will download it again from your links .

Thanks and keep you posted if it works.

SO i was thinking while outside, i noticed something, when you talk about .32 firmware, you talk about the PIE firmware (9.0) right?

I'm stuck in OREO, because when i tried the first time to update to PIE i lost the camera. Since i unlocked on OREO, i went back to OREO following this (from you):

If you unlocked it on OREO,

Downgrade to OREO (needs fullwipe to boot the device) (i used the one on your link wich is the 51.1.A.11.51

Execute XPERIFIX on OREO (custom installation, VENDOR, A/B, magisk.zip) & permissive.zip (only in oreo)

Take a picture on OREO (if the camera preview works, all is correct) -> only do it once on a device

Upgrade to PIE

fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img -> if any error happen, you use the wrong fastboot version

Install camerafix.zip in TWRP

I used the proper twrp, but didnt worked.

Should i try to go back to PIE with newflasher?

Thanks!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] wee2000:
Hi, i browsed this thread abt 10 pages, but couldn't find any solution on my issue. I'm using H8216, downloaded 2019-08-10_17-49-19_twrp_sodp_xz2.tar, & followed the guides.

i was able to perform fastboot flash vbmeta vbmeta.img & it flashed successfully.

then i fastboot boot twrp-xz2.img & it flashed successfully too.

but when it reboots, my device would hang on a blue screen with blue led.

When i did a hard reset/restart by holding vol up + power button for few secs, it would reboot with sony logo & keeps rebooting.

thats the furthest i could go. Appreciate any helps..

---------- Post added at 07:58 PM ---------- Previous post was at 07:55 PM ----------

previously, on older devices, we are required to flash the twrp to replace the stock recovery by fastboot flash recovery recovery.img, but i haven't been playing with sony phones quite a while, seems the ways had changed..
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ASMstudent:
I believe twrp didn't boot up on aosp while it booted up fine on stock rom because I had to execute the vbmeta line. The problem is I get the error "unkown option -- u^ ". knowing that I'm using latest platform-tools, correctly flashed usb drivers and flashed AOSP rom more than once using same application.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Please don't use -- u^ and the twrp made for the SODP based custom ROMs
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ASMstudent:
I didn't use the -- u . It was the error message i had in twrp when I executed the command "fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img"
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
You mean in fastboot and not twrp.

Or are you trying to use this command in the twrp adb shell?

But disabling vbmeta is only needed if you modify the ROM with as example the camerfix.zip on stock.

Installing TWRP or MAGISK don't need this.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ASMstudent:
Yes in fastboot.

Booting up twrp on stock works fine without the vbmeta line, but on aosp it gives me the red error message " the device is corrupt is corrupt and can't be trusted, shutting down in 5 seconds " so I figured out the vbmeta command is the problem. But I get the unknown option error in fastboot.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Please don't do "fastboot flash boot twrp.img" if you do that

Otherwise there is no usecase where it could modificate the ROM in a way it would trigger an AvB 2.0 error.

The unknown option error indicates either an old fastboot version or a paste & copy error
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ASMstudent:
I've been trying whole day and this is the result almost every time;

-Booting and flashing twrp on stock ROM works.

- installing aosp on my device with twrp installed deletes twrp and replaces it with aosp recovery

- trying to boot up twrp on aosp reboots the device into bootloader without booting up

- trying to flash twrp on aosp bricks the device

- disable verity ....... Command always comes back with error on both my laptop and PC .
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Please don't flash TWRP, just boot it. (As stated in the instructions)

And please use the SODP twrp for the SODP based ROMs here.

And yes, AOSP gets removed since there is no recovery partition and TWRP is now part of the bootimage.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ASMstudent:
Thanks for your help

I realized what I was doing wrong

1- using same twrp image for both stock and aosp

2- using hardware buttons to access fastboot to boot twrp

Avoiding both got me to install aosp and twrp both working perfectly
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Anti-root:
Could you, please, write your WHOLE procedure in detail? Because, as you can see here, I have tried many times to install TWRP in AOSP and install Gapps without success. (https://xdaforums.com/showpost.php?p=81229037&postcount=1097). (I did not use the same TWRP. I did not use the hardware buttons to access fastboot. What version is your fastboot? Maybe this was/is my mistake... I cannot think of anything else. Now I have 1.4.3 but I wait for yourt post before I try again)

Thank you! :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ASMstudent:
1-I flashed full stock

2- then flashed aosp without flashing userdata.

3- I booted up aosp once then shut down the device

4- plug type c cable while holding volume up

5- in fastboot I typed fastboot reboot bootloader

6- after reboot I flashed userdata img I'm aosp

7- without rebooting the device, I typed fastboot boot twrp.img

8- after it booted up I flashed TWRP permanently through TWRP.

9- rebooted to recovery from TWRP and it booted up

At one of my trials, TWRP failed to mount storage so I flashed userdata ( or formatted userdata; I can't actually remember ) again and rebooted and it was no longer a problem
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Anti-root:
Thank you. I will try it tomorrow. Yes, I did exactly the same, except that when it refused to boot, I did not format userdata (your last step). I will try that too.... do you have Gapps and Magisk? When did you flash them, if you have?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ASMstudent:
I flashed them after flashing TWRP and booting it up.

Don't forget to mount system in TWRP before flashing gapps or magisk.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] wee2000:
I was using stock ROm, still unable to get TWRP to work, so never has chances to flash any ROMs yet.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] old.splatterhand:
Installing fastboot drivers on Windows is nothing less than a pain!

I had adb working (with the drivers from Sony's website), but fastboot not.

When the phone was in fastboot mode i had a Sony device called "Sony sa0118 ADB Interface Driver" in device manager with an exclamation mark. And additionally an Android device also with an exclamation mark. Pointing the Android device to the drivers from Sony's website didn't bring success.

The solution was to search for already installed drivers. In the list of installed drivers i found my "Sony sa0118 ADB Interface Driver", which I have chosen.

After that i had two "Sony sa0118 ADB Interface Driver" devices in device manager. I deleted the one with exclamation mark and fastboot was working after that.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
The generic winusb drivers are working fine, too.

The Sony xz2 driver is from 2017. Quite old.

I would prefer the build in winusb driver, which gets updates.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nasko_spasko:
[MENTION=6031898]MartinX3[/MENTION] the google usb driver works fine for me - Windows 10 1803. Just install the device manually from device manager. As for the info about mounts and stuff, I'll test after an hour from now. Sorry needed my phone during the weekend. :) So, that's that. Uploading details in a bit. Cheers!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] twistedddx:
Windows 10 driver issue will likely be that the driver is unsigned.

You need to disable driver signature enforcement via Windows 10 troubleshoot startup mode.

Google Windows 10 disable driver signature

Once installed you can boot normally and use.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Thank you all :)

And

Woohoo.

But I can continue to work at Thursday evening. :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] sToRm//:
That's impossible and useless. The device must be unlocked and rooted. Without, the fix will not work. It has to write to the system partition and is executed as root. A modified kernel ramdisk only would be without any effect.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] FartyParty:
Does anyone have the slightest idea why Sony removed the recovery partition to begin with?

Why now? Why wait so long before doing something like this? Why couldn't things be as simple as with the pre-XZP models.

Also I'm curious what the next series will be. I heard XZ3 will be the last phone in the XZ series.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nasko_spasko:
Because of seamless updates specification (A/B partitions) the recovery is in the boot.img as an alternative ramdisk.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Thank you!

Did you installed twrp into

the stock

or

the aosp build (and wiped user data)

?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
https://github.com/sonyxperiadev/bug_tracker/issues/169#issuecomment-424278920

I planned a new build on thuesday with the new kernel fixes.

But now I will wait.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] FcukBloat:
I will probably get root faster on my next new phone than this one.. :mad::laugh:

not your fault of course mate, only thinking loud :laugh::crying:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
You don't need the DRM patch for nice photos.

Keep using opencamera :P
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] niaboc79:
So you can confirm that opencamera works without issue. Great
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
[MENTION=8004595]FartyParty[/MENTION] did confirm it earlier in this topic with his XZ2 Premium. :)

Even without loosing your DRM keys, you can compare the stock photos with the opencamera photos and barely see the quality difference.

I think in the AOSP build you won't need a DRM fix to use the camera (at 17MPinstead of 19MP).

Maybe my friendly testers can confirm a working opencamera app with the stock firmware?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nasko_spasko:
I've flashed the images(boot,system,userdata,vendor,dtbo,vbmeta,oem,etc...) from your aosp build. The data was wiped, yes.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] niaboc79:
Yeah I saw this but someone else claim that the camera doesn't work neither with open camera...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
[MENTION=1337045]nasko_spasko[/MENTION] ? :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] niaboc79:
That's the post
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Thank you!

Good to know that the OEM and other stuff from the aosp ROM changed nothing.

So there is something faulty in the twrp image.

The "invalid argument" error is weird.

Maybe I can't use the same twrp.fstab from the XA2
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ASMstudent:
I'm new to Sony too

1- AOSP and OMNI aren't flashable through twrp but rather flashed in fastboot

2- TWRP - SODP aren't meant to be used on stock ROM but on AOSP ( for stock ROM you'll find a stock folder under twrp in Sony xz2.

If you want aosp and twrp, you should visit aosp link and follow instructions, then boot the TWRP image you're already using then flash twrp as instructed here (i.e. from the booted twrp not fastboot).
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] nico_dh:
Martin, what happens if you fastboot flash boot twrp.img (t might be something i did and now i can't go into twrp or adb reboot fastboot, only get fastboot if i use buttons )

Is there a way to revert this? (flash a standard boot.img for example?)

thanks.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Yes, don't worry

just flash the boot.img back.

If you're using the stock firmware, just throw the boot.sin and newflasher in a single folder.

(If you did need the vbmeta modification before you now need to do it again)