[Nexus 5X Android Development] nathanchance:
Introduction

Hello everyone, this is a guide to get you up and running with your own build of Pure Nexus for the Nexus 5X. In this thread, you will learn how to get your computer set up to build and the commands you will need to run. Please read the entire guide and the FAQ. Additionally, this is a developer's thread, there should be no off topic discussion.

Compilation Guide

This is available on my Github, where it may be a little more up to date.

0. Getting started

In this guide, I will go over how to build Pure Nexus on your Linux machine. This particular tutorial will focus on Ubuntu 16.04 as that is what I use (Mint 18 is also good) but this should work with any version of Linux; it does need to be 64-bit however. I will leave the installation of that up to you, Google is a wonderful resource. If you don't have a good computer but still want to build, check out this thread on XDA: http://xdaforums.com/chef-central/android/guide-how-to-build-rom-google-cloud-t3360430

1. Set up your environment

1. Automatically

sudo apt-get install git-core
git clone https://github.com/akhilnarang/scripts
cd scripts
ls
bash <script-name>

<script-name> should be one of the scripts in the folder for your particular architecture.

2. Manually

1. Install Java 8

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

2. Install other build tools

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 ccache libgl1-mesa-dev libxml2-utils xsltproc unzip

2. Configure repo and git

If you have any problems with the below commands, try running as root:

sudo -s

Git is an open source version control system which is incredibly robust for tracking changes across repositories. Repo is Google's tool for working with Git in the context of Android. More reading if you are interested: https://source.android.com/source/developing.html

Run these commands to get repo working (only do this if you did the manual set up method above:

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

Run these commands to get git working:

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

3. Download the source

First, before downloading the source, create a folder for the source and move into it.

mkdir ~/<foldername> (eg. mkdir ~/PN or ~/PureNexus)
cd ~/<foldername>

Then, we need to grab the manifest and sync down the repositories. Here are the commands to do this for Pure Nexus for Nougat (make sure you are in the source folder you made above):

repo init -u https://github.com/PureNexusProject/manifest.git -b n
repo sync --force-sync

Here is the process generally for other ROMs:

When you go to build a ROM, you must download its source. All, if not most, ROMs will have their source code available on Github. To properly download the source, follow these steps:

Go to your ROM's Github (e.g. http://github.com/PureNexusProject)

Search for a manifest (usually called manifest or android_manifest).

Go into the repo and make sure you are in the right branch (located right under the Commits tab).

Go into the README and search for a repo init command. If one exists, copy and paste it into the terminal and hit enter.

If one does not exist, you can make one with this formula:

repo init -u <url_of_manifest_repo>.git -b <branch_you_want_to_build>

For example:

repo init -u http://github.com/PureNexusProject/manifest.git -b n

After the repo has been initialized, run this command to download the source:

repo sync --force-sync

This process can take a while depending on your internet connection.

4. Build it!

At this point, it'd be a good idea to set up ccache. ccache is a compiler cache, it stores previously compiled files in a directory and pulls from that instead of recompiling if nothing has changed. This speeds up compilation a LOT. If you want to use it, follow the below steps:

Open up your .bashrc file in your home directory using a text editor or nano and append this to the end of it:

export USE_CCACHE=1

Then type:

source ~/.bashrc

After that, run one of the below command (replacing the # with how many GBs of ccache you want, 50 is recommended)

Use this one if you used the manual method of set up in section 1:

prebuilts/misc/linux-x86/ccache/ccache -M #G

Use this one if you used the automatic method of set up in section 1:

ccache -M #G

After that, it's time to build!

. build/envsetup.sh
breakfast bullhead
mka bacon

After that, your computer will build the flashable zip file and if you see something that says make completed, you've done it!

Any time that you want to rebuild, type the following commands:

repo sync --force-sync
. build/envsetup.sh
breakfast bullhead
mka clobber
mka bacon

I also have a script to do this on my Github here

Frequently Asked Questions

1.1 Q: I got an error, what do I do??

1.1 A: Well to start, if it is anything with Ninja, I would go ahead and disable it. You can add this to your .bashrc file:

export USE_NINJA=false

Then type this

source ~/.bashrc
. build/envsetup.sh
breakfast bullhead
mka clobber
mka bacon

If it is saying you ran out of memory, follow this post.

If it isn't Ninja related, check out @AzraelsKiss's post here, where he has documented a few common issues. If none of those apply, post here with a detailed list of what you have done and we will do our best to help you.

1.2 Q: Can you guys share your personal builds?

1.2 A: No, personal builds are just that: personal. Beans releases whenever he feels that the release is ready for the masses and if a bunch of personal builds are floating around, that tarnishes the Pure Nexus name. We are more than happy to help get you up and running but we will not be sharing our builds. Thanks for understanding!