[ROM] [Android] [Linux] [Nougat] compile AOSP ROM

I reckon the vast majority of Android users are aware the openness of Android system, including compiling your own Android Operating System based on your own standard of software. I will take about building your own Android ROM in this post

Android is an open source software stack for a wide range of mobile devices and a corresponding open source project led by Google. This site and the Android Open Source Project (AOSP) repository offer the information and source code you need to create custom variants of the Android stack, port devices and accessories to the Android platform, and ensure your devices meet compatibility requirements. We also wanted to make sure there was no central point of failure, where one industry player could restrict or control the innovations of any other. The result is a full, production-quality operating system for consumer products with source code open for customization and porting.

  • – Google

Getting Things Ready

You need a distro of Linux or Unix systems, Mac is also find, for more information about Mac, go to this link, you can also use a virtual machine, but unfortunately, you cannot use Bash on Windows

Install the necessary packages

We use Ubuntu 15.04 (x64) as an example

  1. Install the Java runtime environment, if you have installed the OpenJDK 8 JDK and JRE before, please skip to the next step
    sudo apt update
    sudo apt install openjdk-8-jdk openjdk-8-jre
  2. Install build essential and other packages  (Ubuntu 14.04+ x64)
    sudo apt install bc schedtool lunzip 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 ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
  3. Installing and setting up git
    If you have problems running, try use root privilege, if you don’t got problems, don’t use the command below, skip to the next one
    sudo su

    make a directory for repo

    mkdir ~/bin

    Modify environment variables

    PATH=~/bin:$PATH

    Download Repo Binary

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

    Change repo permissions

    chmod a+x ~/bin/repo

    Set the user name and e-mail address

    git config --global user.name "your name here"
    git config --global user.email "your email here"

Download the Android Source Code

Each AOSP release version (such as Lineage OS and PureNexus) has a manifest file. The manifest tells your computer where to download the files that needed. Use my PureNexus custom release as an example

Now, we need to make a folder to store all your files, you don’t want them to be all over the place

mkdir ~/AOSP_Build

Enter folder

cd ~/AOSP_Build

Initiate Manifest

repo init -u https://github.com/cydia2020/manifest.git -b nougat-pn-unoffical

Download source code

repo sync --force-sync

Depending on your Internet connection, the download may take 30 minutes to few hours

Compiling Android

At this time you may want to consider enabling CCACHE, CCACHE can accelerate your compiling speed for the next compilation, because it can store things already compiled so that your computer can directly access them next time (highly recommended)

export USE_CCACHE=1
source ~/.bashrc
prebuilts/misc/linux-86/ccache/ccache -M **G

** Is the number of storage you want to assign to CCACHE, assigned as much as possible

To start compiling

. build/envsetup.sh
brunch xxxx yyyy

XXXX is your device, and yyyy is the compiling type (default is user)

XXXX can be the following devices in PureNexus, depending on your ROM, this might be different
Pixel XL: marlin
Pixel: salfish
Pixel C: dragon
Nexus 6P: angler
Nexus 5X: bullhead
Nexus 6: shamu
Yyyy can be of the following type in PureNexus, depending on your ROM, this might be different
Debug: Debug
Debugging: userdebug
User: user

After compiling, you should see a directory on your Terminal

Update or recompiling

repo sync --force-sync
rm -rf out/
brunch xxxx yyyy

If you think this article will be useful for others, please share it

Thanks for PureNexus Project, The Flash on xda-developers




No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.