Tag Archives: custom rom

Easy way to add custom packages to a LineageOS4MicroG ROM

So you have figured out how to build your own custom ROM using Docker…if not click here.
Once you have become an expert at it you would want to add a custom touch to the build. I realized that I was downloading a few apps which I wanted to use. For example – twitter, whatsapp, nextcloud and so on. Now remember these are apps which are not going to be installed by default as they are owned by different organizations and due to licensing issues they cannot and will not be a part of any Lineage ROM that you will download officially from the web. So what do you do?

Simple you add the apk’s to your custom build. Remember as long as you are not going to going to distribute it online you should be ok because as mentioned these applications are licensed to different organizations and not open source.

Steps to add a custom apk to your ROM.

Please note : This method works on the docker setup environment.

Step 1:

Download the apk (s) of your choice. For e.g. say I downloaded nextcloud , Nextcloud notes and twitter apks.

Step 2:

Create a folder with the apk name for e.g. NextCloud or Notes. Something short and simple.

Step 3:

Copy paste the downloaded apk into the folder. Remember to download the correct apk to the designated folder 🙂

Step 4:
Change the name of the apk file. For e.g. the name of the NextCloud apk is com.nextcloud.client_3.3.0-30030099_minAPI14(arm64-v8a,armeabi,armeabi-v7a,x86,x86_64)(nodpi)_apkmirror.com.apk!!!! (download it yourself if you think I am joking)
Rename the apk to something simple for e.g. NextCloud.apk
Do not worry renaming will not impact your build.
Step 5:

Add an Android.mk file with text like below to each of the folders. The below is the sample I always use.
Two values need to be changed in this file.
One the LOCAL_MODULE and the other the LOCAL_SRC_FILES.
For e.g from the below example the words FDroid and Fdroid.apk need to be replaced by the apk folder name and the apk name. If I am adding the NextCloud apk then the value for LOCAL_MODULE will be the folder name i.e. NextCloud and the value for LOCAL_SRC_FILES would be NextCloud.apk.

Similarly you have to create Android.mk files for each of the apks that you are adding.

Each folder will have one apk file and one Android.mk file with the below contents

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

Step 6:

Now make a few additions to the following file


Browse down to the PRODUCT_PACKAGES +=

The default line may look like this – (your file would be different from this these are just samples)

PRODUCT_PACKAGES += FDroid GmsCore GsfProxy FakeStore MozillaNlpBackend NominatimNlpBackend com.google.android.maps.jar FDroid FDroidPrivilegedExtension

Add the names of the custom packages you have added to make it look something like this

PRODUCT_PACKAGES += FDroid Flym GmsCore GsfProxy FakeStore MozillaNlpBackend NextCloud NominatimNlpBackend Notes com.google.android.maps.jar FDroid FDroidPrivilegedExtension Telegram Twitter WhatsApp WordPress

save the common.mk

Copy the complete list of packages as you would need it in the next step

Step 7: Pass the package list copied from the previous step and pass it to your docker run command for example now your command should look like …with all the custom packages being passed.

docker run \
-e “BRANCH_NAME=lineage-15.1” \
-e “DEVICE_LIST=tissot” \
-e “SIGN_BUILDS=true” \
-e “CCACHE_SIZE=100G” \
-e “SIGNATURE_SPOOFING=restricted” \
-e “CUSTOM_PACKAGES=FDroid Flym GmsCore GsfProxy FakeStore MozillaNlpBackend NextCloud NominatimNlpBackend Notes com.google.android.maps.jar FDroid FDroidPrivilegedExtension Telegram Twitter WhatsApp WordPress ” \
-v “/home/username/lineageos4microg/lineage:/srv/src” \
-v “/home/username/lineageos4microg/zips:/srv/zips” \
-v “/home/username/lineageos4microg/logs:/srv/logs” \
-v “/home/username/lineageos4microg/cache:/srv/ccache” \
-v “/home/username/lineageos4microg/keys:/srv/keys” \
-v “/home/username/lineageos4microg/manifests:/srv/local_manifests” \

Step 8: Once the build is complete. Pick it up from the zips folder and flash on your phone.

Check all the apps you installed are running

Step 9: Congratulate yourself for having built your customized ROM!!!


Build a LineageOs4MicroG ROM using Docker on Ubuntu

One month back if anyone had said that I could build a ROM using Docker I would have laughed. I had taught myself how to build a custom ROM for my cell phone the hard way. I have three phones at home. The three phones have three different flavors of the Android Operating system. My current daily driver is a MiA1 tissot. The phone was released with Nougat and was later updated to Oreo. The current version of Oreo is 8.1. The phone is officially supported by LineageOs4MicroG. That is where I decided to try my hand at using Docker to build my own ROM. After a few false starts it finally worked. Now it works like clockwork. Let me share what I did with you.

Before we proceed let me explain what MicroG is. To those – like myself – who do not want to have Google services on their phone and yet are addicted to apps like twitter, whatsapp or GooglePay – MicroG is a must. The problem with Google is that, their apps tend to steal your personal information and marketing it. I do not like that. Yet I need to use apps like WhatsApp and Twitter. These apps need Google play store to run in the background. The way around is to install MicroG. What MicroG does is it spoofs the apps into believing that Google Play is installed on your phone!

Installing Micro G the standard way- downloading apk’s and installing them- is a pain. The easiest way is to either download a custom ROM with MicroG already built in or build a custom ROM yourself. This is where LineageOS4MicroG comes in. These builds require docker to be setup on your PC.

A word about Docker.

Docker is a build method which is almost entirely automated. Once you have the environment up and running on your PC you just sit back and wait for the build to complete. No action is required from your side. Lets see what the per-requisites are for setting up a Docker build environment.

Step 1:
Install docker on your PC. I use a Ubuntu PC but Docker can be installed on windows as well as Mac.

Check the docker web site for instructions specific to your system.

Confirm that docker is installed on your PC by running the below command

run hello-world

the output should be something like this

docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world ca4f61b1923c: Pull complete Digest: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. ...

Step 2: pull the lineageos4microg on to your pc

pull lineageos4microg/docker-lineage-cicd

You should see a screen similar to the screenshot below….this was for another pull..but you get the idea 🙂

docker pull image

Step 3:

Create directories

sudo mkdir -p \

/lineageos4microg/src \

/lineageos4microg/zips \

/lineageos4microg/logs \

/lineageos4microg/ccache \

/lineageos4microg/keys \


this would create directories on the file system. The lineageos4microg environment takes up about 150 GB of space so I do not prefer creating folders outside /home as I ran into space problems

An easier way is to just create folders using nautilus under home for e.g.

Create a folder lineageos4microg under home

and inside it create these 6 folders


Step 4:

Create an xml file… copy paste this in notepad, gedit and save with the name custom_package.xml

The name is not important, it is the .xml part which is important.

<?xml version=”1.0″ encoding=”UTF-8″?>
<project name=”lineageos4microg/android_prebuilts_prebuiltapks” path=”prebuilts/prebuiltapks” remote=”github” revision=”master” />

Step 5:

start the build with the below command

docker run \
-e “BRANCH_NAME=lineage-15.1” \
-e “DEVICE_LIST=<device name>” \
-e “SIGN_BUILDS=true” \
-e “CCACHE_SIZE=100G” \
-e “SIGNATURE_SPOOFING=restricted” \
-e “CUSTOM_PACKAGES=GmsCore GsfProxy FakeStore MozillaNlpBackend NominatimNlpBackend com.google.android.maps.jar FDroid FDroidPrivilegedExtension” \
-v “/home/manoj/lineageos4microg/lineage:/srv/src” \
-v “/home/manoj/lineageos4microg/zips:/srv/zips” \
-v “/home/manoj/lineageos4microg/logs:/srv/logs” \
-v “/home/manoj/lineageos4microg/cache:/srv/ccache” \
-v “/home/manoj/lineageos4microg/keys:/srv/keys” \
-v “/home/manoj/lineageos4microg/manifests:/srv/local_manifests” \

Please note:

– replace the <device name> with your phone name. For e.g. my MiA1 is called tissot. You can get your device name by typing the below adb command

$ adb shell getprop ro.product.device

assuming you have adb setup and functioning on your pc. If not click here xxxxx

– in the above command I have set Ccache size as100G. This is because I have a lot of empty space on my PC. Set it to 50G or as per your convenience.

– the PC will seem to hang with the message Syncing repositories. This is because the setup is downloading files from the internet. This process can take a long -long time. You can see what is happening by checking the log files. Copy the logs on to your desktop and open this copy. Do not try to open the actual logs as data is being written on to it.

what these commands mean:
All the command starting with the -e are setting your environment for the build. The cache size, Lineage branch (in this case 15.1) , signature spoofing – read detailed documentation links to understand this better. Safe to say use restricted for now.
All the commands starting with the -v are the location of your source files or folders where your logs and zip is to be placed. I got errors here when the path was not correct.

Check the path to get the command to run smoothly. It is a one time task. Save the command to run it again the next time you want to build.

The \ sign mark the end of each line.

To see more samples refer the links given below for the LineageOS4microG site.

Step 6:

Once the build is complete you will find the build in the zips folder.


The advantage of the Docker build is once the environment is set up it does all the work almost automatically. The resources on the PC are optimally used. For e.g. I have 15 GB or RAM but am unable to run any other application while building normally. With Docker I use my PC as normall while the build is running in the background. You can run multiple device builds at the same time, You just have to add device names separated by a comma.

Additional reading for reference and trouble shooting

Docker installation : get details for your PC

For e.g. for Ubuntu https://docs.docker.com/install/linux/docker-ce/ubuntu/

LineageOS4MicroG related documentation

How to flash lineage official OTA on the MiA1

Let me explain the process of how to flash lineage official OTA on the MiA1. The reason why this needs a separate post is because it is slightly complicated and the chances of failure are high. The process of flashing the lineage ROM on the MiA1 has changed now that we have a signed Over the Air (OTA) ROM coming in every week on Tuesday.
I am assuming that you have a basic understanding about flashing ROM’s  and understand why custom ROM’s are flashed. I am also assuming you know about platform tools like adb and fastboot and have a working adb and fastboot on your PC.

WARNING: As always remember there is a good chance  that the process of flashing custom ROM’s can seriously damage your phone and even permanently brick it i.e. render it useless. You have been warned  and are doing so at your own risk.

Now that we are done with the warning lets start flashing.
Before you proceed download these files.
Please note these files are available either from this web site or you can search for them on the web and download them from their original sites. I leave the option to you. The point is you would need these files to continue with the task at hand.

Copy required files
Copy the boot recovery image file into the folder where you installed adb on your PC.
Copy the remaining files on to your phone. These files are Lineage ROM for 10 July + Mind the Gaps + TWRP installer.
Copy them into the download folder on your phone. You can either use the PC or try it through adb push is you are comfortable with that.
The command for an adb push would be as under

adb push TWRP-installer-3.2.1-with-Tissot-Manager-2.3.zip  /Downloads
adb push <complete file name to be pushed including extension> /<destination>

Coming from Stock MiA1 ROM follow the steps given below. These steps should be the same even if you are coming from other unofficial version of the Lineage ROM  and want to install the official lineage ROM.


Step 1. Boot phone into fastboot mode

From a PC which has adb and the correct drivers installed type the above command to boot the phone into the fastboot mode. This is the mode where you get the picture of a bunny wearing the Chinese army hat!

Alternately you can also switch off the phone. Press and hold volume – and power button and keep holding till you feel it vibrate. This should happen in 1-2 seconds. Then release. The bunny in the hat should be on your screen now!

Step 2 : From the folder where you have installed adb and copied the Boot recovery image type the below command in the console.
fastboot boot boot-recovery.img

Within 2-3 seconds the boot image will be hot booted on you phone and you should be in the TWRP screen.

Step 3. Wipe cache, data and system

Step 4. Flash the Lineage Official ROM for July 10. This is a slightly weird step required because flashing the latest ROM directly will give you an signature verification error!!!
Hope this error is fixed in later versions of the ROM.

Step 5. Flash the TWRP installer .
This TWRP is by CosmicDan and specifically create for the Tissot. Please note the TWRP screen will give you very detailed instructions at each stage of the installation. Read it carefully. In spite of all the help on this page or the Lineage  web sites the setup may still fail in some cases. That is where the messages on the TWRP screen would come in handy. Read the messages and you would be able to resolve most of the issue on your own.

Step 6.   Reboot Recovery. This is a required step
Step 7.   Flash Magisk 16.6
Step 8.   Flash Mind the gapps
Step 9.   Reboot System
Once you have the ROM up and running. Go to  System >> About phone >> Tap the build number 7 times and you will be into developer mode. Enable USB debugging and Advance restart. If you are not familiar with these steps click here for details  
This is just in case you are stuck again and need to recover your phone then it would be helpful to have USB debugging enabled on your phone to allow access through adb from your PC.

Now remember you are in the July 19 version of the ROM.

To get the latest OTA update

  • Go to System >> About Phone >> LineageOS updates and click to download the latest build for your phone.

    This is a painfully slow download so have patience and relax.
    The download from the lineage web site can take hours. It took about 4 hours on my phone that too on a 10 MB internet WiFi connection!
    Once the download is complete install the build . This will also take some time.
    Preparing for first Boot

When the build is finally installed, you can check the results in settings.
The latest ROM released on the Tuesday of the current week should be showing up.

Here there is an important thing to note. Once the new ROM is installed it will wipe out your magisk and TWRP installation .
Mind the Gapps will work seamlessly.
Flash TWRP and magisk again if you need them.


Best of luck!

A Noob’s guide to building a Lineage ROM

As the title mentions, this is a guide by a noob which spells out the steps that build a lineage ROM. What the title does not mention is that this article is aimed at noobs as well. Now lets get down to business.


Disclaimer: Please note that by following the steps as mentioned in this article you can seriously damage your smart phone. There is a good chance your phone would be bricked i.e. effectively be rendered useless and cause a lot of frustration, irritation and make you pull at your hair. If you hit that point later, Please do not look towards me to save you since I am also new to this and like you learning how to traverse this parallel universe of custom ROM development. That being said do not despair. As the saying goes browse and you shall find – Check out the internet and you would find others who have messed up their smartphones and yet somehow lived to tell the tale. In most cases you would be able to revive your phone. Ideally do not use your daily driver for such experimentation.

After reading all this if still want to go ahead then read on.
Build a custom lineage ROM for your smart phone. I own a Xiaomi MiA1 and used the same as my target phone. You may have a different model but technically the build steps should be the same for all android phone models.

A linux based or a Mac computer.
Windows computers do not directly support the tools required for this type of development. As such they are not being covered in this article.
The recommended operating system is Ubuntu.

Other requirements:

  • A basic understanding of Linux based OS specifically Ubuntu.
  • Ability to type and use the command line. Write or copy paste commands in the Ubuntu konsole.
  • A basic understanding of programming concepts, read and update XML files, understand error messages.
  • Fast internet access.
  • Steady electricity supply.
  • Lots and lots of patience.

You will understand why the last three requirement are mentioned as you read on

Hardware recommendations – ideally your system should exceed these conditions

  • 64 bit environment
  • 100 GB of free hard disk space
  • 16 GB RAM / swap space.

My hardware configuration:

  • Intel i5 processor
  • 16 GB RAM
  • 1 TB hard disk.
    Please note even with this configuration it takes me about 3 hours to build the code!
    Operating system:
    I used the Ubuntu 18.04 build which is the latest at the time of writing. I will be covering only the Ubuntu OS as part of this article as I do not have a Mac and as such it is out of scope for me!

Steps to build the Custom ROM from scratch
Step 1: Setup Ubuntu
Assuming you have set up the Ubuntu OS if not click this link for a detailed explanation of the installation of Ubuntu.
Step 2: Installation of Java Development Kit
In a console window type or copy past the below commands.
Wait for one line of command to execute before typing or pasting the next

sudo apt-get update
sudo apt-get install openjdk-8-jdk

Please note the sudo command will ask you to enter your password.

Step 3: Installing required packages ( this is a single line not multiple lines)

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip

Step 4: Configure your smart phone access

These tools will provide you access to the device once you have complete the

build and are ready to flash the Rom.

sudo apt-get install android-tools-adb

sudo apt-get install fastboot

Step 5: Creating your work directories

mkdir -p ~/bin

mkdir -p ~//lineage

Step 6: Installing Repo

The Android source tree is located in a Git repository and is hosted by Google. The Git repository includes metadata for the Android source. Repo is a tool that makes it easier to work with Git .

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

Next type below command to make repo executable.

chmod a+x ~/bin/repo

Step 7: Initialize your lineage source

Now change directory and move into the newly created lineage folder.
You can do this either by Opening nautilus and right clicking inside the lineage folder and selected ‘Open Terminal here’ or by typing the below command

cd ~//lineage

Important: Ensure you are in the lineage folder before executing the next set of commands

Step 8: Configure your Git user

You can set these on the GitHub website. Once you have set your GitHub web site

Type \ paste these commands. Replace the text within “ ” with your credentials.

git config –global user.name “Your Name”

git config –global user.email “you@example.com”

Step 9: Initialize the repo

repo init -u https://github.com/LineageOS/android.git -b lineage-15.1

A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.

Step 8: Download the source code

This is the step where you will realize the importance of having a fast internet connection. The source code size is about 30 – 35 GB. I have a 10 mbps line and at times the download speed shoots up to 20- 25 mbps!!!  Yet it takes me anything from 4 – 10 hours to download the code!
My suggestion is check the time when your local ISP download speeds are at its best. For me it is during the night. I set the download up at night and go to sleep!

The command to type \ paste to get the source code is :

repo sync -c -f –force-sync –no-clone-bundle –no-tags –optimized-fetch –prune

Optional Step 8 a: Take a backup of your source code

I copy the entire folder and keep a copy on an external device. This is just in case there is any need for me to format my hard disk. I do not copy the .Repo and .Cache folders on to my backup. To check hidden folders press Ctrl + H.

Step 9: Get the source code for your specific device.

This is an important part to understand. The code which you downloaded is generic in nature. For your particular device you would need to get files which are specific to your device.
The source for all these files is github. You are targeting three sets of folders – Device, Kernel and vendor. The git clone commands given below are for the tissot or Xiaomi Mia1 phone. Similarly other phones have their locations on GitHub from where you can get files specific to them.

git clone https://github.com/TheScarastic/andr…msm8953-common -b lineage-15.1 device/xiaomi/msm8953

git clone https://github.com/TheScarastic/andr…_xiaomi_tissot -b lineage-15.1 device/xiaomi/tissot

git clone https://github.com/TheScarastic/prop…_vendor_xiaomi -b lineage-15.1 vendor/xiaomi

git clone https://github.com/Tissot-Developmen…_xiaomi_tissot -b 8.1 kernel/xiaomi/msm8953

The format of the command will remain the same for all phones only check the url and the folder names.

Step 10: Modify Caching to speed up the build process.

Type \ paste one command at a time and wait for it to execute before posting the next.

export CCACHE_DIR=./.ccache
ccache -C
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 50G

Step 11: Configure JACK

JACK is the java compiler and can cause crashes – believe me! A simple fix is this command which you type next
export _JACK_VM_ARGS=”-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G”

Step 12: Cleaning up the build folder

make clean

Step 13: Initializing the build

source build/envsetup.sh

Step 14: Starting the build

brunch tissot


Now sit back and wait for a few hours. Check the screen, occasionally for what is happening. There will a ton or warnings showing up.Do not worry about the warnings. Read the message displayed on the screen for clues as to what is happening.
The entire build took about 3 hours on my machine with nothing else running. This duration can increase and decrease based on the configuration of your build machine. It can also depend on the files downloaded during the Repo sync process.

Finally you will get the .iso file in a folder labeled out. Check the screen shot above. It shows the build settings screen. Have been using it as on my main driver and so far so good.

Handling Error messages:

There is a very good chance that the build will stop many times. When this happens read the error message and then try googling it. I can guarantee that there would be number of other people across the world who have faced similar issues while building their custom ROM’s. See what solutions have been suggested and try them out. It took me almost a week to get my first build right!
Then in the same day I got 2 builds in a row that were successful! It has a lot with having all the right files in the build environment + a good hardware configuration + lots of luck!

At times the error message which stopped the build could report that a particular file is not found in a particular folder. Do a search in the base lineage folder and see if the file is there in any other folder. Simply copy it to the folder where the build is expecting it. After that run the build commands again and restart the build.

Remember to use your default login. I used su – superuser and ran into trouble while doing a repo with the normal login. So I do not use su for the build and do the entire build and repo sync with my login.  Since i installed the system Ubuntu is satisfied with my credentials.

As I mentioned at the start this is my first shot at building a custom ROM. While there is not exactly much customization being done here as the source code is available on Lineage.com and the files specific to the device were shared by various developers on GitHub. All that I have done is that I downloaded the code and recompiled it on my machine. Having said that there is a sense of pride that you feel when you see your name in the settings tab!!!!

Hope this was a easy to understand guide to help noobs around the world do their own custom ROM development. This article is as I mentioned a guide, you should refer the links given below and get a complete understanding of the process of building ROM’s before you start on your own. So good luck with your custom ROM building!!!

Some important links which you should visit to understand how the experts do it.

Build ROM from source for Tissot 
The Android Source Code
How to build your own custom Android ROM

To download the build click the links below:
Please note that you are downloading and installing the build at your own risk. I will not be responsible for your phone bricking up and also will not be able to support you in case of any issues.

On a personal note I have been using the same build on my daily driver for the last couple of days with no issues. I have GApps installed and am able to use some 46 apps with no issues including Twitter, Whatsapp, Quora, XDA, WordPress among others. The phone camera and fingerprint features are working normally.

Download Links


TWRP Recovery Installer:

GApps Aroma 64bit ( please note all arm64 bit variant work,but i prefer Aroma as it gives me the option to select what I want to install. You can download the latest Gapps from here


Fix for the camera in case it does not work

The process to flash the build is given here. Please use the same sequence to avoid issues.

Installing a Custom Rom on the Xiaomi MiA1


Read the warning before Installing a Custom Rom on the Xiaomi MiA1

Warning: Installing or Flashing a Custom ROM voids the warranty of your smart phone. So unless you are sure you want to do this and have a basic idea of ROM and how to flash them on smart phones, there is a good chance you may brick your phone. Please proceed at your own risk.

Now that you have been warned and despite it if you would want to risk your sanity and the sanctity of your smart phone then read on…

Process to install a custom ROM on the Xiomi MiA1 has been updated. The process for a clean flash is as under

  1. Open up ADB on your PC. Steps to start or install ADB on your PC are given here.
  2. Check ADB is detecting your phone. There should be a number followed by devices. If it shows as unknown device or something else please read the instructions given here
  3. Remove phone lock if enabled on your phone- this could be a pattern or fingerprint. Set it to none under Settings >>Security & Privacy >> Screen lock
  4. At the command prompt type
    adb reboot bootloader
  5. This should take your phone into the boot loader mode.
  6. At the command prompt type
    fastboot devices
  7. When you see your device showing up type the following at the command prompt
    fastboot boot boot-recovery.img
  8. Wait for a few seconds your phone screen will display the TWRP main screen
  9. Go to the main menu, and tap Wipe.
  10. Now tap Format Data and continue with the formatting process. This will remove encryption as well as delete all files stored on the internal storage.
  11. Return to the previous menu and tap Advanced Wipe.
  12. Select the System partition to be wiped and then Swipe to Wipe.
  13. Place the LineageOS .zip package, as well as any other .zip packages on the root of /sdcard:
    • Using adb: adb push filename.zip /sdcard/
    • You can use any method you are comfortable with. adb is universal across all devices, and works both in Android and recovery mode, providing USB debugging is enabled.
  14. Go back to return to main menu, then tap Install.
  15. Navigate to /sdcard, and select the LineageOS .zip package.
  16. Follow the on-screen prompts to install the package.
  17. Once the Lineage OS is installed install TWRP immediately.
  18. Reboot to recovery. This will take you to the TWRP recovery. This is an important step for the MiA1 as it has two partitions.
  19. Once you are in the TWRP push the other files using adb push commands to the same /sdcard/ folder
  20. You can push the Magisk, Open Gaps and Camera fix zip files. All the urls for all the files are given on this page.
  21. Install in the following sequence
  22. Magisk
  23. OpenGapps
  24. Reboot system

Wait for the phone to reboot. It will take a few minutes to start.

————————————Previous Article __________________

Files to Download before proceeding

  1. Custom ROM of your choice. I prefer the Lineage 15.1 Unofficial version downloadable from here

Please note this is the site of the XDA forum for MiA1. To read more details on XDA and the other ROM options available please scroll down.

  1. TWRP and recovery
    Download both the recovery image and the TWRP installer. Please check which version you are downloading as both the nougat and the Oreo version are available at the site. The choice will depend on which OS you have on your MiA1 currently. For e.g. if it is the Oreo 8.0 version from Xiaomi that you want to overwrite then download the oreo version of TWRP. Click here to download
  2. Google Platform Tools.

Once you have the files installed on your PC copy the recovery img downloaded in Step # 2 about and place it in this folder. Preferably on C Drive. To understand what exactly happens here read this article.
Google Platform Tools download urls




This is a suite of Google applications that will install the framework as well as google applications on your phone. Unless you plan not to use Google applications or do any downloads from google Play you will need a version of GApps as well.

I would recommend downloading the Aroma variant as it has a graphical interface where you can pick and choose which google applications to. For example, you can un select Gmail and Duo and the rest of the Google Apps will still work!

The other combinations to choose are Arm 64 and 8.1
All Variant under Arm64 and 8.1 work. PICO has the smallest size when it comes to downloads.

Gapps Url : https://opengapps.org/

  1. Magisk .Download the latest version from here
  2. The fix for the camera. The stock camera tends to misbehave on custom ROM’s. Remember Xiaomi also provides its own camera along with the default ROM!

Download the Google_Cam_Fix_for_LineageOS_v1.0 from here.

Steps to install the ROM

  1. Copy all the above files in your download folder.
  2. Enable developer options if not already done. To read how to do it click here.
  3. Remove any Pattern or Fingerprint locks you may have set. You can do this from Settings >> Security & Privacy >> Device Security >> Screen Pattern set it to none. It will ask you for the pattern to confirm. Select None.
  4. Power Off your phone.
  5. Wait for a minute for the phone to completely power down.
  6. Now there are two options. If you are installing the custom ROM and TWRP for the first time, then you have to Press the power button and the Volume Down – button together.

To better explain what that mean – the volume button is a long button right? Now press the lower end of it along with the power button.

You should feel the phone vibrate in about 2-3 seconds. Let go of all the buttons.

  1. The phone will boot into the Fastboot screen. This image of a Chinese army hat wearing bunny should appear on your screen with the words Fastboot written all over.
  2. Connect your phone via the data cable to your PC. Open command prompt (CMD) and browse to the folder where you have the Google Platform Tools copied.
  3. If you have not unlocked your phone, then you would need to read this and perform these steps first
  4. On your PC open up the command prompt and type
    fastboot devices

This would show you an ID and a device. This is your phone showing up in the fastboot mode.

  1. Now type at the command prompt

fastboot boot recovery…img

where recovery.img is the name of the recovery file you have downloaded and copied in to the Google Platform tools folder.

  1. This will install the recovery image on your phone. Wait for 2-3 seconds and you will get a message saying success.
  2. The TWRP screen as visible to the right will show up.
  3. Swipe to factory reset
  4. Got to Wipe and clear out Data, dalvik,system
  5. Go to Install
  6. Flash ROM zip
  7. Go to Twrp reboot options and switch to another slot (ex. if you are on slot_a then switch to slot_b)
  8. REMEMBER DO NOT REBOOT AT THIS STAGE. You do not have an operating system on your phone and will end up with a bricked phone if you reboot now.
  9. Flash latest Twrp installer
  10. Reboot into Twrp recovery
  11. Flash latest Magisk
  12. Flash gapps zip (platform ARM64 + Android 8.1 + Variant (all gapps will work))
  13. Flash Camera…zip
  14. Reboot to system

Remember the first time it reboots it will take about 10-15 minutes. So have a cup of tea or at least leave the phone alone. Let the OS do its magic. Once it reboots the phone will ask you for the setup details.

Go ahead use a custom ROM and declare your independence!!!

To download the latest build unofficial Lineage build for the MiA1 click the links below:

Please note that you are downloading and installing the build at your own risk. I will not be responsible for your phone bricking up and also will not be able to support you in case of any issues.

On a personal note I have been using the same build on my daily driver for the last couple of days with no issues. I have GApps installed and am able to use some 46 apps with no issues including Twitter, Whatsapp, Quora, XDA, WordPress among others. The phone camera and fingerprint features are working normally.

Download Links


TWRP boot image :
Boot recovery image

TWRP Recovery Installer:

GApps Aroma 64bit ( please note all arm64 bit variant work,but i prefer Aroma as it gives me the option to select what I want to install. You can download the latest Gapps from here


Fix for the camera in case it does not work

Some important links: