Android

 
 
Android is an open and free mobile platform developed by the Open Handset Alliance, a group of more than 30 technology and mobile companies. To develop applications on this platform the Android Software Development Kit can be used.

The latest Android Software Development Kit version can be downloaded from:
http://developer.android.com/index.html

More information about Android can be found at http://developer.android.com/index.html







Installing lineageOS 18.1 and MindTheGapps (ARM64) 11.0.0 on Xiaomi 5S



Information about Mi 5s
The official global operating system installed on the Xiaomi Mi 5s: MIUI 10.2.3.0 (OAGMIXM)
Android version: 8.0.0 OPR1.170623.032 (Oreo)

Installing LineageOS on your Xiaomi Mi 5s (codename: capricorn) is a great way to breathe new life into your device with a clean, customizable, and updated Android experience.

Below is a detailed, step-by-step guide to help you through the process.
Proceed with caution and at your own risk.

Prerequisites
  • Xiaomi Mi 5s with at least 50-60% battery charge.
  • A Windows 10 computer with internet access.
  • USB-C cable compatible with your Mi 5s.
  • Ensure your device has an active SIM card and internet connection (Wi-Fi or mobile data).
  • Back up everything important. For example:
    - Make sure all your contacts are sync in Google Contacts (if you use this).
    - Make sure your tasks are sync in Google Calendar (if you use this).
    - Make sure your notes are sync in Google Keep (if you use this).
    - Make sure your photos and videos are sync in Google Photos (if you use this).
    - Make sure all your WhatsApp, Signal etc. chats are stored.
A. Download LineageOS 18.1
  1. LineageOS for Mi 5s.
    I have found two LineageOS versions and I decided to use Lineage 18.1.

B. Download MindTheGapps 11.0.0 (ARM64)
  1. MindTheGapps provides a single, minimal package with only essential Google services (Play Store, Play Services, Setup Wizard) needed for Google ecosystem functionality.

    No customization options, it's designed for simplicity and compatibility with AOSP (Android Open Source Project) - based ROMs like LineageOS.

    Also uses proprietary Google APKs but focuses on a lightweight, bloat-free experience.

    It's explicitly recommended by LineageOS for 18.1, ensuring compatibility with the Mi 5s.

    MindTheGapps can be found at:
    https://wiki.lineageos.org/gapps/

    The MindTheGapps version used in this tutorial can be found at:
    https://github.com/MindTheGapps/11.0.0-arm64/releases/tag/
    MindTheGapps-11.0.0-arm64-20230922_081122


    The MindTheGapps downloaded:
    MindTheGapps-11.0.0-arm64-20230922_081122.zip
    3d3b8939f9bb2a09c08df4066221114f (MD5)

C. Download and install Xiaomi Mi Flash Tool
  1. Download the latest Xiaomi Mi Flash Tool (for example MiFlash20220507.zip):
    https://www.xiaomiflash.com/download

    There is no official checksum.

    The Mi Flash Tool v20220507 is one of the latest stable releases as of recent updates and works well with the Mi 5s. It supports fastboot ROMs like capricorn_global_images_V10.2.3.0.OAGMIXM.

    The Xiaomi Flash tool is a desktop program and comes with ADB Tool, drivers software files, and flash file.
    Mi Flash Tool works best on Windows 10 or 11. Windows 7 may require additional driver tweaks.

    The MiFlash tool comes with built-in drivers.

  2. Create folder C:\Users\robertlie\Downloads\lineageOS

  3. Unzip MiFlash20220507.zip into folder lineageOS.
    Locate C:\Users\robertlie\Downloads\lineageOS\
    MiFlash20220507\XiaoMiFlash.exe.

  4. Create folder C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507\log,
    otherwise you will get an error when you execute XiaoMiFlash.exe and select Mi Flash Tool menu: Driver.

    Missing log directory

  5. Right click XiaoMiFlash.exe and select Run as administrator to avoid permission issues.

  6. Select Mi Flash Tool Menu: Driver.

    Mi Flash Tool Menu: Driver

    Click button: Install
    This will install the included drivers.
    After installation, the tool may close automatically.
    Restart your PC to ensure drivers are properly loaded.
    Relaunch XiaoMiFlash.exe as administrator.

  7. Boot the Mi 5s into fastboot mode:
    • Power off your Mi 5s.

    • Press and hold the power and volume down buttons together (for 5–10 seconds) until the fastboot logo appears.

      fastboot logo

    • Connect the phone to your PC via a USB-C cable.

  8. Verify device detection.
    In Mi Flash tool (XiaoMiFlash.exe), click Refresh.
    Your device should appear in the list with a serial number (e.g., 12345678).

    Troubleshooting if the device is not detected:
    • Confirm drivers were installed correctly, reinstall if needed from the Driver menu.

    • Try a different USB port, preferably using USB 2.0, as USB 3.0 can sometimes cause issues.

    • Use another USB cable.

    • Verify fastboot mode, type:

      cmd

      cd C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507
      \Source\ThirdParty\Google\Android

      fastboot devices


      This should list your device's serial number.
      For example:
      d3008b0c fastboot

      fastboot devices

      In the MiFlash tool you will see:

      MiFlash

      Ensure the Mi 5s bootloader is unlocked, some ROMs need an unlocked bootloader.

  9. The fastboot.exe and adb.exe are included in the Mi Flash Tool.
    • C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507\Source\ThirdParty\
      Mi\fastboot.exe.
      The Xiaomi-specific fastboot.exe is tailored for Xiaomi devices and often includes optimizations or compatibility fixes for Xiaomi's fastboot implementation (e.g., handling specific commands or quirks for devices like the Mi 5s).

    • C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507\Source\ThirdParty\
      Google\Android\fastboot.exe.
      It is recommended to use this fastboot.exe tool.
      I will be using this fastboot.exe tool in this tutorial.

      The Google fastboot.exe is a generic version from the Android SDK, which is universally compatible with Android devices but may lack Xiaomi-specific tweaks.

    • C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507\Source\ThirdParty\
      Google\Android\adb.exe.
      This adb.exe is the standard Android Debug Bridge tool from Google, included for tasks like pushing files, accessing recovery, or debugging. There is no Xiaomi-specific adb.exe, so the Google version is the only one provided and is appropriate for use.

D. Unlock the Mi 5s bootloader

This step is only needed if your Mi 5s bootloader is locked.

On Xiaomi devices like the Mi 5s, the unlocked padlock icon appears briefly at the bottom of the screen during the initial MIUI logo splash (before the full system loads). This is a deliberate design choice by Xiaomi to show that the bootloader is no longer locked.

Be aware: unlocking the bootloader will erase all data on your device, so make sure to back up everything important.

If your Mi 5s bootloader is unlocked, you can skip this step.
  1. Create a Mi Account:
    • Go to Xiaomi's Mi Account page and sign up if you don't have an account.
      https://account.xiaomi.com

    • Link a valid phone number to the account (required for unlocking).

    • Log in to the Mi Account on your Mi 5s via Settings > Mi Account.

  2. Enable Developer Options & USB Debugging
    • On your Mi 5s, go to Settings > About Phone.

    • Tap "MIUI Version" 7 times quickly to enable Developer Options.
      You'll see a message saying "You are now a developer".

    • Go back to Settings > Additional settings > Developer options.

    • Enable "OEM Unlocking".

    • Enable "USB Debugging".

  3. Link Device to Mi Account:
    • Go to Settings > Additional settings > Developer options > Mi Unlock status.

    • Tap on "Add account and device" to bind your Mi 5s to your Xiaomi account.
      Sign in with your Mi Account (make sure it's linked to your phone number).

    • You'll see a message like "Added successfully. Mi Account is associated with this device".
      This step binds your phone to your Mi Account.

    Important:
    Xiaomi may impose a 7-day (168-hour) waiting period after binding.
    Keep the account logged in and connect to the internet periodically during this time.
    The Mi Unlock Tool will notify you if waiting is required.

  4. Download Mi Unlock Tool.
    • Go to the official Xiaomi Unlock page:
      https://en.miui.com/unlock/index.html

    • Click the "Download Mi Unlock" button to get the latest version
      (e.g., miflash_unlock-en-6.5.224.28.zip).
      This is a native Windows application.

    • Extract the ZIP file after downloading.

    • Find miflash_unlock.exe.
      Right click and "Run as administrator".

    • Approve the Windows User Account Control prompt (“Do you want to allow this app to make changes?”) by clicking Yes.

    • Agree to the disclaimer.

    • Sign in with the same Mi Account linked to your Mi 5s.
      + Email / Phone / Mi Account ID
      + Password

      Note: Use the same Mi Account linked to your phone.

  5. Boot Mi 5s into fastboot mode:
    • Power off your Mi 5s.

    • Press and hold power + volume down for ~5–10 seconds until the fastboot logo appears (a bunny fixing an Android).

    • Connect the phone to your PC using a high-quality USB cable (preferably USB 2.0).

  6. Unlock the bootloader:
    • In the Mi Unlock Tool (miflash_unlock.exe), click Refresh.
      Your Mi 5s should appear with a device ID.

    • Click Unlock and follow the prompts.
      Warning: Unlocking wipes all data (factory reset).
      Back up your data beforehand.

    • If the 7-day waiting period applies, the tool will display a countdown (e.g., "Please unlock after 168 hours").
      Wait and try again after the period ends.

    • Once successful, the tool will confirm the unlock, and the Mi 5s will reboot.

  7. Verify bootloader status:
    • On Xiaomi devices like the Mi 5s, the unlocked padlock icon appears briefly at the bottom of the screen during the initial MIUI logo splash, before the full system loads.
      This is a deliberate design choice by Xiaomi to show that the bootloader is no longer locked.

    • To confirm beyond the icon (in case you're unsure or want technical verification):
      Enter fastboot mode.
      • Power off your Mi 5s.

      • Press and hold power + volume down until the fastboot logo appears.

      • Connect the phone to your PC via USB.

      • Use the Mi Flash Tool (C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507
        \Source\ThirdParty\Google\Android\fastboot.exe).

        Run the command:
        fastboot oem device-info

        fastboot oem device-info

        You'll see lines like:

        C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507
        \Source\ThirdParty\Google\Android>fastboot oem device-info

        (bootloader) Device tampered: false
        (bootloader) Device unlocked: true
        (bootloader) Device critical unlocked: true
        (bootloader) Charger screen enabled: false
        (bootloader) Display panel:
        OKAY [ 0.047s]
        Finished. Total time: 0.054s


        If "Device unlocked: true" appears, your bootloader is unlocked.

  8. The unlocked bootloader allows you to flash custom ROMs, recovery (e.g., TWRP), or other modifications, but it may void parts of the warranty and disable some features (e.g., certain DRM-protected apps).

E. Download and install TWRP Recovery

The TWRP (Team Win Recovery Project) tool is a custom recovery needed to flash LineageOS.
  1. Download the latest TWRP image for "capricorn" from TWRP's official site.
    https://eu.dl.twrp.me/capricorn/twrp-3.7.0_9-0-capricorn.img.html

    More info:
    https://twrp.me/xiaomi/xiaomimi5s.html
    twrp-3.7.0_9-0-capricorn.img
    3d77f1418be6384667478baa72000ef6 (MD5)
    This is an .img file you’ll flash via fastboot.

    Copy twrp-3.7.0_9-0-capricorn.img into
    C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507\Source\ThirdParty\Google\Android

  2. Boot your Mi 5s into fastboot mode:
    • Power off your Mi 5s.

    • Press and hold the power and volume down buttons together (for 5–10 seconds) until the fastboot logo appears (Mi Bunny with "FASTBOOT" text).

    • Connect the phone to your PC via a USB cable (preferably the original or a USB 2.0-compatible cable).

  3. Flash TWRP image and boot into TWRP.
    • Use the Mi Flash Tool (C:\Users\robertlie\Downloads\lineageOS
      \MiFlash20220507\Source\ThirdParty\Google\Android\fastboot.exe)

      Run the command (This will write TWRP permanently):
      fastboot flash recovery twrp-3.7.0_9-0-capricorn.img

      Output:
      Sending 'recovery' (21292 KB) OKAY [ 0.534s]
      Writing 'recovery' OKAY [ 0.128s]
      Finished. Total time: 0.749s

      Wait for confirmation: Finished.


      This command writes the TWRP recovery image (twrp-3.7.0_9-0-capricorn.img) to the Mi5s's recovery partition, replacing the stock MIUI recovery.

    • Immediately boot (launch) TWRP before MIUI can interfere.
      This prevents MIUI from restoring the stock recovery on the first boot.
      The fastboot boot here is just a safety measure to activate TWRP before MIUI can overwrite it.

      Run the command:
      fastboot boot twrp-3.7.0_9-0-capricorn.img

      Sending 'boot.img' (21292 KB) OKAY [ 0.515s]
      Booting OKAY [ 0.453s]
      Finished. Total time: 1.029s


      Note:
      This ensures TWRP loads once, bypassing MIUI's auto-recovery restore.
      On your Mi 5s you will see the TWRP logo screen:

      TWRP screen

    • In TWRP, if prompted, "Swipe to Allow Modifications".
      Do not select "Keep Read Only", this is crucial to avoid issues later.
      When you select "Swipe to Allow Modifications" in TWRP, you're giving TWRP full read/write access to partitions (like /system, /data).

      TWRP swipe to allow modifications

      After you swipe the button (>>>) to the right, you will see the TWRP main menu:

      TWRP main menu

    • Select Reboot -> Recovery.

      TWRP reboot menu

      This step ensures TWRP persists and prevents MIUI overwrite.
      Sometimes, the first TWRP boot can be glitchy e.g., touch issues, encryption errors.
      If that happens, a second reboot into recovery ensures TWRP is fully stable before flashing a ROM.

    • After Reboot -> Recovery, you will see the TWRP logo screen:

      TWRP screen

    • Now modifications are allowed, and there are no "Read Only" restrictions.
      MIUI's recovery overwrite is defeated.

      Select "Advanced Wipe".

      TWRP advanced wipe

      TWRP advanced wipe menu

    • Select the following partitions to wipe:
      • Dalvik / ART Cache
      • Cache
      • System
      • Data

      Do not select: Internal Storage and USB-OTG.

      Note:
      The Xiaomi Mi 5s does not have an SD card slot, meaning it does not support external microSD cards.

      TWRP wipe partitions

      And swipe the button (>>>) to the right.
      This clears the old system, ensuring a clean install.

    • Wiping the partitions progress is shown.

      The partitions are being wiped:

      TWRP start wiping partitions

      The wiping of the partitions is successful:

      TWRP wiping partitions successful

      *** In case of error ***
      If TWRP disappears: MIUI overwrote it.
      Repeat commands "fastboot flash recovery" + "fastboot boot".

    • Select "Back".
      Do not select "Reboot System".

    • Tap on the circle (with the two arrows) next to the title "Wipe, Advanced Wipe" to go back to the main menu.

      TWRP icon

      TWRP main menu:

      TWRP main menu

    • Proceed to Install lineageOS 18.1 and MindTheGapps 11.0.0 (ARM64) on Xiaomi Mi 5s.

F. Install lineageOS 18.1 and MindTheGapps 11.0.0 (ARM64) on Xiaomi Mi 5s

The following steps describes how to transfer and install the LineageOS and MindTheGapps zip files to your Xiaomi 5s using TWRP recovery.
  1. To transfer files there are two methods:
    A. Transfer Files via MTP
    B. ADB Sideload

    First use method A, which is easier. If that fails use method B.

  2. Method A.
    • In TWRP, ensure the device is in MTP mode (Media Transfer Protocol).
      This is usually enabled by default.

      To verify this, in TWRP main menu, select: Mount.

      If MTP mode is enabled you will see option Disable MTP.
      Do nothing and go back by tapping on the circle (with the two arrows).

      If MTP mode is disabled you will see Enable MTP.
      Select this option and go back by tapping on the circle (with the two arrows).

    • Transfer files via MTP.
      On your computer, the Xiaomi 5s should appear as an Internal Storage device.
      Click on the image to enlarge.

      Mi 5s internal storage

    • Copy the LineageOS (lineage-18.1-20230708-UNOFFICIAL-capricorn-signed.zip) and MindTheGapps zip file (MindTheGapps-11.0.0-arm64-20230922_081122.zip) into Mi 5s Internal Storage root.
      This is the default storage location accessible by TWRP.
      Do not copy the zip files in any subfolder.

    • In TWRP main menu, navigate to: Install -> Internal Storage -> Select ZIPs.

      TWRP main menu
      TWRP main menu

      Install ZIP screen.

      TWRP install zip

    • Confirm that both zip files
      lineage-18.1-20230708-UNOFFICIAL-capricorn-signed.zip
      MindTheGapps-11.0.0-arm64-20230922_081122.zip
      are visible and accessible.

    • Install LineageOS.
      • First select the LineageOS zip file and press "Install Image".

      • The "Install Zip" screen is shown with the selected LineageOS zip file.
        Only select checkbox "Skip Digest check before installing zip".

        TWRP select lineageOS zip

      • Select "Swipe to confirm Flash".

      • Installing LineageOS zip file.

        TWRP install lineageOS zip

      • Installing LineageOS zip file successful.

        TWRP install lineageOS zip successful

      • Wait for the installation to complete (usually 1–2 minutes).
        TWRP will show a "Successful" message.

    • Do not reboot yet and proceed to flash MindTheGapps immediately.
      Go back to the "Install ZIP" screen by pressing the circle (with the two arrows).

      You will see this screen:

      TWRP select lineageOS zip

    • Install MindTheGapps.
      • Tap "Add More Zips" in TWRP.

      • Select the MindTheGapps zip and press "Install Image".

        TWRP install zip

      • The "Install Zip" screen is shown with the selected MindTheGapps zip file.
        Only select checkbox "Skip Digest check before installing zip".

        TWRP select MindTheGapps zip

      • Select "Swipe to confirm Flash".

      • The MindTheGapps zip file will be installed.
        Wait for the installation to complete, typically faster than the LineageOS flash.
        TWRP will show a "Successful" message.

        TWRP install MindTheGapps zip successful

      • Flashing MindTheGapps right after the LineageOS flash ensures Google services integrate correctly and prevents crashes.

    • Clear Cache:
      • After flashing both zips, select "Wipe Cache/Dalvik".

      • Select Wipe -> Advanced Wipe.
        Select "Dalvik/ART Cache" + "Cache".
        Swipe the button (>>>) to the right.

        TWRP clear cache

      • The wipe is successful.
        This ensures no residual data will be left, which may causes boot issues.

        TWRP wipe successful

    • Reboot:
      • Return to the TWRP main menu and select Reboot -> System.

        TWRP main menu:

        TWRP main menu

      • The first boot may take 5–10 minutes as LineageOS 18.1 sets up.
        You'll see the LineageOS boot animation.

      • If it takes longer than 15 minutes or loops, you may have a bootloop.
        Redo previous steps:
        Reboot to TWRP > reflash LineageOS zip + MindTheGapps zip -> Wipe cache.

  3. Method B (If Transfer Files via MTP does not work).
    Note: I have not tested this option.
    • Enable ADB Sideload in TWRP:
      In TWRP, go to Advanced -> ADB Sideload -> Swipe to start.
      Your device will wait for a file from your computer.

    • Connect Device to Computer:
      * Use a USB cable to connect your device to your computer.
      * Open a terminal or command prompt on your computer.

    • Verify Device Connection:
      Type: adb devices

      To confirm your device is detected.
      You should see a device serial number with "sideload" next to it.

    • Send file via ADB sideload:
      • Use the command:
        adb sideload lineage-18.1-20230708-UNOFFICIAL-capricorn-signed.zip

        Note:
        Use C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507\Source\ThirdParty\
        Google\Android\adb.exe.
        • Type: adb version to confirm it's functional.
          For TWRP sideload, ADB version 1.0.32 or newer is typically fine.

        • Ensure the folder also contains AdbWinApi.dll and AdbWinUsbApi.dll, as these are necessary for ADB to work on Windows.
          If they're missing, the sideload command may fail.

        • To avoid typing the full path every time, copy the
          LineageOS (lineage-18.1-20230708-UNOFFICIAL-capricorn-signed.zip) and
          MindTheGapps zip file (MindTheGapps-11.0.0-arm64-20230922_081122.zip) to
          C:\Users\robertlie\Downloads\lineageOS\MiFlash20220507\Source\ThirdParty\
          Google\Android\ folder.

      • First sideload LineageOS zip, second sideload MindTheGapps zip.

    • Wait for transfer and installation:
      • The file will transfer to your device, and TWRP will automatically install it once the transfer completes.

      • Monitor the progress on both your computer and device.

    • Reboot device:
      • Once LineageOS and MindTheGapps installation is complete, go back to TWRP's main menu and select Reboot > System.

      • The first boot may take 5-10 minutes.

  4. Verify installation:
    Once LineageOS boots, set up the device (language, Wi-Fi, etc.).
    • Check for Google apps:
      Open the app drawer and confirm Play Store is present (MindTheGapps includes minimal apps, so only core services like Play Store and Google Play Services are installed).

    • Sign in to your Google account to verify GApps functionality.
      If crashes occur, reflash MindTheGapps.

    • Verify TWRP is permanent:
      • Power off and boot into recovery (volume up + power).

      • If TWRP loads, it's preserved (LineageOS doesn't overwrite custom recoveries like MIUI does).

      • Confirm LineageOS version:
        Go to Settings > About Phone and check that it shows LineageOS 18.1 (Android 11).


  5. After you have setup your mobile with all your required apps, install the Google Files.
    Remove the LineageOS (lineage-18.1-20230708-UNOFFICIAL-capricorn-signed.zip) and MindTheGapps zip file (MindTheGapps-11.0.0-arm64-20230922_081122.zip) from the Mi 5S Internal Storage root.