How to Install Android Pie sGSI on Xiaomi Mi A1

If you want to get the latest Android Pie sGSI on your Xiaomi Mi A1, its really a simple process that just involves flashing a lot of different files via TWRP. The important thing to remember is that because we will be doing a repartition of your userdata, your internal storage will be wiped.

There are a few known bugs with this release:

  • DT2W only works on some display panels
  • Some issues with the Mi A2 Camera app (“Could not connect to Camera” crashes often)
  • SELinux is permissive

But everything else should be working perfectly fine, and if not, it is more than likely a vendor issue and you should contact your ROM dev. You can restore your apps via Google Backup or Titanium Backup if you engage those options before beginning to follow this guide.

Requirements / Downloads:

  1. First enable Developer Options on your Xiaomi Mi A1 by going into Settings > About > tap ‘Build Number’ 7 times, until Developer Mode is activated.
  2. Now go into Settings > Developer Options > enable OEM Unlocking and USB Debugging.
  3. Now connect your Xiaomi Mi A1 to your PC via USB, navigate to your ADB installation folder, hold Shift + Right click and choose ‘Open a Command Window Here’.
  4. In the ADB terminal window, type: adb devices
  5. A dialogue should open on your Xiaomi Mi A1’s screen asking to confirm the ADB pairing. Confirm it, then re-type ‘adb devices´ into the ADB terminal.
  6. If the ADB connection is successfully recognized, the ADB terminal should display your device’s serial number. If no device is recognized, you may need to troubleshoot the ADB connection (USB cable coming loose, etc).
  7. Now extract the TWRP fastboot only version .img file from the .zip you downloaded earlier, and place the .img file inside your main ADB path.
  8. Place the CosmicDan’s TWRP Installer .zip on your SD card.
  9. In ADB terminal, type: fastboot boot recovery.img (replace recovery.img with actual filename)
  10. Your Xiaomi Mi A1 should reboot into a temporary version of TWRP. You should now install the CosmicDan’s TWRP Installer as a flashable zip through the TWRP install menu.
  11. Once TWRP has been successfully flashed, you can reboot your Xiaomi Mi A1 by typing: fastboot reboot
  12. Once your Xiaomi Mi A1 boots into the Android system, start copying the remainder of the required downloaded files to your device’s SD card.
  13. Now in the ADB terminal, type: adb reboot recovery
  14. This should reboot your Xiaomi Mi A1 directly into TWRP recovery.
  15. Once inside TWRP, you need to go to TWRP Tissot Manager via Advanced > Tissot Manager > select the ‘Repartition Userdata’ option.
  16. Choose ‘Singleboot’ and then press Repartition.
  17. Now flash the Vendor.img as a Vendor Image.
  18. Flash the A/B system Pie PR2.img as a System Image
  19. Then flash the POST-sGSI 1 tissot zip and POST-sGSI 2 tissot zip files.
  20. Now you need to flash a kernel that is compatible with Treble – such as Moun, ProjectK, or Velocity.
  21. Finally, reboot to system.

Once you’re inside the Android System, you need to install the latest Google Play services, either as manual APK installation or via ADB flash. This will fix the Pixel Setup and Google Backup issues, and you can also access the Play Store without further issue.

If you want root via Magisk, you can install Magisk 17.1, which is Treble-compatible.

You should install the Data Transfer Tool APK as well.

At this point, there are a couple tweaks to do to fix some things. First, to enable USB MTP, you should go into Developer Options and change the File Transfer option to USB MTP.

Enable the Navbar

To enable the nav bar, you need to install the Nav Bar Enabler via Magisk. Reboot your Xiaomi Mi A1, then Settings > System > Gesture and enable Swipe Up on Home Button to enable the Nav Bar Gestures.

Installing Substratum

If you install this Substratum APK from the Telegram channel, it has much better support for Android Pie. After building the themes, you need to reboot, then go into Manager and enable the overlays for the theme you have built.

Updating from PR1 to PR2

You don’t need to wipe data to update from PR1 to PR2. You just need to wipe SYSTEM, then flash PIE PR2 AB GSI, and reboot to system.

For updating your post GSI zips, you need to wipe VENDOR, flash the vendor, then flash the POST zips and reboot to system.

OK Google

Install the latest Google App update from the Play Store. Download the April or July modem patch and flash via TWRP. See which one makes OK Google work for you.


Library of GCam mods (not all of them will work, depends on the device):

Kamil Anwar
Kamil is a certified MCITP, CCNA (W), CCNA (S) and a former British Computer Society Member with over 9 years of experience Configuring, Deploying and Managing Switches, Firewalls and Domain Controllers also an old-school still active on FreeNode.