[Xiaomi Mi A2 Lite Guides, News, & Discussion] BubuXP:
TROUBLESHOOTING

WARNING: before attempting any of the following operations, you must disable any screen lock, PIN or password, because you risk to not get back your data (encryption issues). It is recommended to take a backup, too (as every time a custom modding is involved).

You can get errors when installing OTA updates if you didn't follow meticulously the guide.

Check this list to try to find where the problem lies:

- when a new version is found, the updater will check if all the partitions on the device are untouched. If there is a partition that has been modified, the OTA updater will not proceed with the installation;​

- typically, the two partitions commonly modified by user modding are the boot partition (that's where Magisk and TWRP are installed) and the system partition (when you change a config file, add or remove a system app, etc.);​

- a system partition modified only by using Magisk modules is effectively untouched, because Magisk register all changes to /system in a file in the /data partition and then trick Android to believe those changes are really applied to /system;​

- boot partition instead is really modified, but if you install Magisk following this guide, Magisk will save a copy of the untouched boot partition, and restoring it before applying OTA update will make the update work.​

Now, if you didn't follow this guide to install Magisk and you installed it in other ways, Magisk could alert you that he cannot restore the original boot.img (the boot partition) when you try to apply the OTA update.

To fix this, you can flash directly the vanilla (original, unmodified, untouched) boot.img taken from the point 6 of this guide, using those commands:

fastboot getvar current-slot
fastboot flash boot_? boot.img

the first command will tell you what is the current slot in use (a or b), the second command will flash the original boot into the phone, but you have to change the "?" in the command with a or b (i.e. the current slot that the first command provided).

Remember that the boot.img file version must correspond to the Android build version currently running in your phone.

If the OTA update will still refuse to apply, probably you changed something directly in the /system partition (for example you changed something in the build.prop without using a Magisk module to do this).

In this case you have to flash the original system.img in the phone with those commands:

fastboot getvar current-slot
fastboot flash system_? system.img

and as before, the first command will tell you the right slot to use instead of the "?" in the second command.

Here you can find the system.img extracted from the OTA updates zip (along with every other .img file inside that):

9.6.6.0 (August 2018) OTA update dump as .img files

9.6.8.0 (September 2018) OTA update dump as .img files

9.6.9.0 (October 2018) OTA update dump as .img files

9.6.10.0 (November 2018) full fastboot ROM

9.6.11.0 (November 2018) OTA update dump as .img files

If you want to obtain the system.img by yourself, you can find it inside the fastboot images but usually they are not updated monthly like OTA updates. But you can extract the system.img directly from the OTA update zips found in this thread (as I did above with my dumps), using the Python scripts found here.

To make the Python scripts work in Debian/Ubuntu and derivatives, you have to download both "extract_android_ota_payload.py" and "update_metadata_pb2.py", give them execution property and then install the package "python-protobuf". After this you can give this command to unpack the payload.bin file (that you must extract from the OTA update zip):

./extract_android_ota_payload.py /path/to/payload.bin

This will extract in the current directory all the .img files inside payload.bin, including the system.img

I don't know how to proceed in Windows, probably you only need to install the latest Python2 release and the script will work.​

As the last resort, you can flash directly with MiFlash the latest fastboot image available (even if older than your current version). Use the "flash_all.bat" script but before take a backup of your data, because the phone will be fully reset.

If you don't want to take the risk of not doing a backup, use the script "flash_all_except_storage.bat" when flashing, so you will keep all your data, but be warned that sometimes you will not be able to access the data anymore, because of encryption problems.

Right after the flash, you can start following the guide from point 5 or 6.

It should not be a problem downgrading the build version via fastboot, as long as the Android main version remain the same (Oreo 8.1 at the moment).