Skip to content

Building CUSTOM ROM

Posted on:November 2, 2024 at 09:49 PM

Guide on Building Android Custom ROM

Prerequisites:

Requirements for Building an Android ROM

To build an Android ROM, you need the following:

  1. Device Tree
  2. Kernel Tree
  3. Vendor Tree

You can find these trees on the LineageOS GitHub repository. Some devices may require additional trees, depending on the model.

Since I am building Evolution X for Google Pixle 7a also known as lynx, I need to modify my device tree to adapt it for this ROM. Here are examples for:

After these modifications, we’re ready to begin building.

Installing Required Packages

For Ubuntu 24.04, use:

sudo apt install git bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick lib32readline-dev lib32z1-dev libelf-dev liblz4-tool libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev

For Arch-based distros, use:

yay -S git aosp-devel

Setting Up the Build Environment

First, create the necessary directories:

mkdir -p ~/bin
mkdir -p ~/evo

Install the Repo command:

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Configure Git:

git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git lfs install

Enable caching to speed up builds:

export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
ccache -M 50G

Set the cache size between 30-50GB for building a single device.

Downloading the ROM Source Code

Since we’re building Evolution X, follow the Evolution X sync instructions.

Navigate to the build directory and initialize the repository:

cd ~/evo
repo init -u https://github.com/Evolution-X/manifest -b udc --git-lfs

Sync the repository:

repo sync -c -j$(nproc --all) --force-sync --no-clone-bundle --no-tags

This process may take a few hours, depending on your internet speed.

Preparing Device Trees

For the Pixel 7a (Lynx), here are the trees to clone:

For each tree, use:

git clone <repository-url> <target-directory>

Example:

git clone https://github.com/razinares/device_google_lynx -b Evolution-X device/google/lynx

Once all trees are cloned in the correct directories, you can start the build.

Building the ROM

Switch to the build environment:

. build/envsetup.sh

Set the build type with lunch. Evolution X uses the lunch command (some ROMs use brunch):

lunch lineage_lynx-userdebug

Where:

The three build variants:

Start building Evolution X:

m evolution

The build process may take a few hours. For example, on my Ryzen 3600, it takes about 3 hours.

After a successful build, navigate to the output directory to retrieve the necessary files:

cd $OUT

For flashing, you’ll need:

If you encounter issues, use adb logcat to review logs, troubleshoot errors, and resolve any issues.

References:

Happy Building!