[Xiaomi Mi A2 Lite Guides, News, & Discussion] LinkBoi:
Heya,

This is a guide aimed on helping you to switch to a custom rom from the stock firmware.

For any questions, feel free to join our Telegram groups.

PREREQUISITES

1) Stock rom recommended by the maintainer of the rom that you want to flash. Typically for Q roms, 10.0.13.0, 10.0.18.0, 11.0.4.0 work well. (Link here).

2) The custom rom you want (Custom Rom list here).

3) Platform-Tools by Google for adb and fastboot (Link here).

4) TWRP Recovery Image and installer zip (Link here and here).

5) Force Encryption Disabler (Link here).

6) MiFlash by Xiaomi (Download the latest version from here).

7) An unlocked Bootloader

INTRODUCTION

Installing a custom ROM on an Android phone used to be a walk in the park. However, some newer phones, like Xiaomi Mi A2 Lite, have what's called an A/B partition layout. This facilitates an update process on stock ROMs, however it makes it harder to install and develop custom ROMs. You can read more about A/B partitions here.

The upshot is that Mi A2 Lite doesn't have a recovery partition. Instead, when you install TWRP, it gets installed to the boot partition. Which means that every time you install or update a ROM, you will need to re-flash the recovery ZIP. One more thing to keep in mind is that the ROM always gets installed to another slot. Meaning, if you're currently in the slot B, the ROM will be installed to slot A and vice versa.

INSTALLATION PROCESS

A) Installing Stock Rom as a Base

1) Extract the platform tools zip file and open the new extracted folder.

2) Open a command line / PowerShell window in that folder by holding the shift key and right clicking into the empty space of the folder. Press the "open PowerShell / Command line window here" option.

3) Plug the device into your PC with a Micro USB cable.

4) Hold down the power button and the volume down button for ~10-15 seconds. You should see the fastboot screen.

5) In the Command Line / PowerShell window type: "cmd" and hit Enter. Then, type "fastboot oem edl" and hit Enter again. If your device can't get detected (Stuck on "Waiting for any device") and nothing happens on your phone's screen, check the notes section of the guide below.

This will reboot your device into edl mode (Emergency Download Mode). The screen should turn off and the led indicator should be blinking indefinitely

5) Extract the MiFlash zip file and open the extracted folder

6) Launch the Mi Flash application by double clicking the XiaoMiFlash.exe file

7) Install the necessary drivers for MiFlash (Click ok in the dialogues).

8) Extract the downloaded stock rom.

9) Press the "select" button and point into the previously extracted folder. (There should be an images folder and some other sh and bat files in the same directory).

10) Click "Clean All" all in the bottom left.

11) Press "Refresh".

12) Your device should appear (COM port). (If not, check the notes section of the guide below)

13) Click "Flash". The process will take around 200-350 seconds.

14) After it is done, hold down the power button for ~10 seconds and verify that the stock rom boots.

DO NOT UPDATE OR MAKE ANY MODIFICATIONS IN THE BOOTED STOCK ROM IN ANY WAY.

B) Install the Custom Rom

(If you want to flash PixelExperience Official, continue with this guide by the PE team. If you face any issues, check the NOTES section of this guide)

1) Paste the downloaded custom rom (zip file) into your sd card and insert it into your phone.

2) Hold down the power button alongside with the volume down button. You should see the fastboot screen shortly.

3) Copy the TWRP IMG file to the platform-tools folder

4) Copy the TWRP Installer Zip file to your SD Card.

5) Open a cmd / PowerShell window in the platform-tools folder (like Step 2 of Section A)

6) Type: "fastboot boot twrp-3.4.0-3-unofficial-daisy.img".

7) You will see the recovery on your phone, prompting you to enter the password. Choose "Cancel"

8) Go into the main menu of TWRP. Press Wipe, then "Format Data". Type "yes" and press enter. (Keep in mind that all of your data will be wiped and there is no going-back).

9) Go back and press "Advanced Wipe". and select everything except "SD Card". Swipe to confirm the action.

10) Go into the main menu. Press "Install", "Select Storage" and select "Micro SD Card".

11) Flash the zips in this order (Click on them and swipe to confirm the action)

- Custom ROM

- TWRP Installer ZIP

- Force Encryption Disabler

DO NOT install Magisk, GApps or anything else yet, we will do that later!

(Some ROMs do not require Force Encryption Disabler as Force Encryption is disabled by default, although flashing that zip won't hurt anything)

After everything is done, DON'T TAP REBOOT YET. Instead, go back to the main menu, choose "Reboot", change the slot (e.g. if it says "Current Slot: A", tap "Slot B", vice versa.

12) Tap "Recovery" in the reboot menu.

13) Copy anything you would like to install on your phone (Magisk, Gapps, etc.) and flash it the usual way (optional)

(Some roms like EvolutionX and Pixel Experience have Gapps built-in so do not flash any gapps package in such roms.)

(Flashing Magisk isn't necessary but some roms may need it for CTS / SafetyNet to pass.)

14) Reboot to System and enjoy your Rom.

DIRTY FLASHING / MANUALLY INSTALLING A NEW BUILD

Manually Installing a new ROM build a.k.a Dirty Flashing is also somewhat complicated on A/B phones like Xiaomi Mi A2 Lite. However, if you follow these steps, you should be good to go:

1) Download the new build and copy it to your phone.

2) Reboot into the recovery mode (hold power + volume up) and flash the ROM ZIP.

3) Here's where the fun part begins: since we've just overwritten the boot partition, we don't have TWRP anymore, so we need to flash it again.

4) Once again, after you're done, don't tap on "Reboot" yet, instead, go back to the main menu, change the slot, and tap "Recovery".

5) Once the phone boots into recovery again, flash Magisk (optional) and Gapps if you had flashed them before.

6) Reboot the phone to system.

PSA: Dirty Flashing rom builds may cause unexpected problems and for this reason, it is recommended to perform a clean flash (Format Data) every time you want to flash a new build of your rom or switch to a different one.

SEAMLESS UPDATES

LOS Updater (which is used in Lineage OS and many other roms) downloads the ROM ZIP automatically and installs it to the inactive slot, which spares us the need to reboot into recovery. Thus, these updates look like OTA updates from the stock rom. However, there are a few gotchas here too:

After the OTA is installed, DON'T TAP ON "REBOOT". Instead, go to Magisk Manager and install a module called "TWRP A/B Retention Script" (you should be able to find it in the "Downloads" section)

Then, go to the Manager's main menu, tap on "Install" and choose "Install to inactive slot (After OTA)"

After the installation process is completed, you can reboot. You have to repeat the process every time you get an OTA if you want to keep Magisk and TWRP on your newly updated system.

- - - - NOTES - - - -

- Windows is the only supported operating system by this guide.

- If when you type a fastboot command (like fastboot oem edl) it just shows "Waiting for any device", it is probably due to missing drivers. See this page on how to install the Google USB driver that is required for fastboot to detect your phone.

- If you have an older version of Windows like 8, 8.1, 7 etc, your device might not get detected by MiFlash due to missing drivers. In this case, you will have to install the Qualcomm EDL driver on your own (Link here). Windows 10 finds and installs the driver automatically.

- If SafetyNet doesn't pass, ensure you have not modified anything in the system partition and that you have enabled Magisk Hide in Magisk Manager. If it still does not pass, try using the "MagiskHide Props Config" Magisk Module (More Info here). If it still doesn't work, try reinstalling your rom. If there are still issues regarding safetynet, it may be the rom's problem or google's new server-side changes might have affected your device (Learn more here)

- If some apps detect root and do not function properly (like banking apps), make sure SafetyNet passes. Also, you can try selecting the app in the MagiskHide section of Magisk Manager. The "Hide Magisk Manager" option in the Settings of Magisk Manager can be useful too.

- MIUI Roms / Ports have a special installation procedure (different from the one presented here) and thus, it is recommended that you take a look at their respective xda thread(s) and / or in the appropriate telegram group.

- If your download speed is slow when downloading the stock rom base, try using a download manager like IDM. If the speed is still slow, it is an issue with xiaomi's servers and there is nothing that can be done about it.

- 3.18 kernels such as butterfly, dragonheart etc, do NOT work and / or cause unexpected issues in updated custom roms because these roms use newer 4.9 kernels. The recommended custom 4.9 kernel is Sleepy and it can be found on Telegram (https://t.me/Laciakerneltg). Therefore, there will be no support offered if you are using a 3.18 kernel in a ROM that uses 4.9 kernels (all new UPDATED roms do)

- If your fingerprint doesn't work / partially works, flash this fix in twrp (This issue exists in the official version of pixel experience)

- Android 11 ROMs might require extra steps that are not mentioned here, please follow the respective maintainer's installation guide for now.

CREDITS

tkchn for some parts of the guide

@Offain for FED

@FDoop for some links and guides