After a LOT of trial and error I am making a description, how to get a running LOS on your SONY XZ2 Compact Single SIM (and probably Dual SIM). This is not a description for people, who got it running the easy way. It's for people that tried everything, and can't get it running, and are in desperation and lost.
General description first: The SONY XZ2 Compact is a phone with 2 slots. These phones don't have a recovery partition, so you cannot meaningfully boot into a recovery partition like on old phones. It now has a boot partition (2 of them - slot A and slot B), and you can boot an operating system from these slots. These slots are completely separate, you can boot an operating system in slot A and another separate one in slot B. These slots (from a user perspective) are separate, and there is very little interchange between them (or more or less none).
Prerequisits: TWRP, I used the Version from MartinX 2020-06-14_21-07-37_twrp_apollo.tar.gz , link is here:
https://androidfilehost.com/?w=files&flid=306949
Use a STOCK TWRP
Extract the .img files with 7-zip (7-zip.org), until you have the .img file separate.
Newflasher:
Disclaimer: newflasher tool was made for testing and educational purposes, ME is not responsible for what you do on/with your device using newflasher, you must agree that you using newflasher on your own risk, I am not responsible if you brick...
forum.xda-developers.com
I used v42, probably newer versions work, too, try not to use an older version
Booting into fastboot: hold Volume-UP and then plugging a USB cable to the computer. The blue light should be lit, if fastboot is active, screen stays blank.
Booting into flash mode: hold Volume-DOWN and then plugging a USB cable to the computer. The green light should be lit, if flash mode is active, screen stays blank.
Now let's get to the process of flashing LOS:
Step 1 - Flash an original working SONY image into Slot A:
Boot into fastboot mode, so the blue light is on.
Type:
fastboot reboot bootloader
(Sometimes the computer doesn't recognise the phone after this command, then just unplug the USB, wait until the phone is off, and try again beginning Step 1. It can fail a couple of times, but it will also work in between).
fastboot --set-active=a
fastboot reboot bootloader
You can check that Slot A is active by typing the command
fastboot getvar all
in the output check the line current slot active: a
Run Newflasher (how to use Newflasher is beyond the scope of this post, google it) to flash an original stock SONY image. You need to be in flash mode for Newflasher with the green light lit.
Answer the first question what to do when done with Newflasher with 'p'=Power Off, and all others with 'n'=No.
When Newflasher completes, check the last few lines output, it should say setting slot A active and OKAY. That confirms that you flashed the original SONY image in Slot A.
You now have a fully working operating system in Slot A. However there is a bug in Newflasher and that bug destroys the boot process in Slot B, which means you'll be only able to boot Slot A, booting Slot B will fail.
Should you decide to boot the operating system (you don't have to), make sure you don't set up authentication (pin code, fingerprint), skip setting that up, so your data partition doesn't get encrypted.
Step 2 - Flash an original working SONY image into Slot B:
Boot into fastboot mode, so the blue light is on.
Type (similar to Step 1):
fastboot reboot bootloader
fastboot --set-active=b
fastboot reboot bootloader
You can check that Slot B is active by typing the command
fastboot getvar all
in the output check the line current slot active: b
WARNING: DO NOT BOOT Slot B, as it will fail 2-3 times (you'll notice the phone vibrating upon crash and reboot), because the phone will then put you back on Slot A, and you'll flash Slot A again. Make sure YOU DON'T BOOT the operating system in Slot B, or you'll end up in Slot A again.
Run Newflasher (how to use Newflasher is beyond the scope of this post, google it) to flash an original stock SONY image. You need to be in flash mode for Newflasher with the green light lit.
Answer the first question what to do when done with Newflasher with 'p'=Power Off, and all others with 'n'=No.
When Newflasher completes, check the last few lines output, it should say setting slot B active and OKAY. That confirms that you flashed the original SONY image in Slot B.
You now have a fully working operating system in Slot B. However there is a bug in Newflasher and that bug destroys the boot process in Slot A, which means you'll be only able to boot Slot B.
At this point in time, if you would try to boot into Slot A, it will boot up to the SONY logo, and then crash, and reboot up to the SONY logo, and then crash. Should you get stuck in that loop, insert a USB cable and hold Volume-UP, it'll catch the crashing loop, and you'll end up in fastboot.
Step 3 - Boot the original SONY image up to the home screen where the apps show:
Actually you should be in Slot B already, but if you are not:
Boot into fastboot mode, so the blue light is on.
Type (similar to Step 2):
fastboot reboot bootloader
fastboot --set-active=b
fastboot reboot bootloader
You can check that Slot B is active by typing the command
fastboot getvar all
in the output check the line current slot active: b
Boot the phone's operating original stock image in Slot B, until you are at the home screen with the apps. This sets up all the defaults for your phone, and updates any ROM images in the chips (like modem etc.).
Make sure you don't set up authentication (pin code, fingerprint), skip setting that up, so your data partition doesn't get encrypted.
Power off your phone.
Step 4 - Flash twrp into Slot B
Type (similar to Step 2):
fastboot reboot bootloader
fastboot --set-active=b
fastboot reboot bootloader
fastboot flash boot twrp.img
This will flash TWRP as boot in Slot B. Make sure in the screen output it was flashed in boot_b.
Should you make an error here, start with Step 1. The reason here is, we want LOS in Slot A, and not TWRP.
Boot your TWRP in Slot B.
WARNING: DO NOT flash VBMETA, it'll break the boot process, and you can start from Step 1.
Step 5 - Flash LOS into Slot A
Once TWRP is running, go to Wipe.
WARNING: DO NOT perform factory reset.
Go to Advanced Wipe, and ONLY WIPE 'Data' and 'Dalvic Cache'
WARNING: DO NOT WIPE System or Internal Storage. You'll loose mount points under Linux, and the LOS image flash will fail.
Go back to TWRP home screen.
From there go to Advanced and from there to ADB Sideload.
From the computer start installing your LOS image (sideload).
On the computer type:
adb sideload <Your LOS image>.zip.
ATTENTION: During flashing, the phone will show, which slot it flashes. It should flash and show: "flashing inactive Slot A". If you accidentally flash Slot B, start from the beginning Step 1.
Best results I had with the image from the LOS homepage
https://download.lineageos.org/xz2c
Download the zip file, don't unpack it, use adb sideload to upload the zip file.
Forget about the Recovery image on the LOS homepage. You don't need it.
When flashing completes, you can wipe Delvic Cache.
WARNING: DO NOT WIPE 'cache', since a 2 slot phone doesn't have a cache partition, and it will fail to wipe it.
Do NOT install the TWRP app, skip this step.
Reboot
Step 6 - Boot LOS
LOS is in Slot A, TWRP is in Slot B.
You can alternate between the slots from fastboot.
fastboot reboot bootloader
fastboot --set-active=a
fastboot reboot bootloader
A reboot should boot LOS.
ATTENTION: When the LOS image has finished booting and you get to the date/time screen, the LOS will hang a while (30s). Just let it do it's job, I think (not sure), it's creating the data in the user partition. After 30s or so use the back key, and try setting the time again. This only happens on the very first boot.
Let me know as feedback, if I can clarify better or if this description is ok.