[Android] sylentprofet:
--- reprinted with permission from nathanpfry.com ---

--- If you would rather use a ready-to-go Virtual Machine based on these instructions, check out this post! ---​

With a new version of Ubuntu comes an update to my guide for setting up a build environment to compile Android ROMs. The aim of this is to simplify the configuration process and teach a little bit about the command line.

Follow the directions step-by-step. All you have to do is copy and paste the code in order, it will be up and running in no time!

This guide applies to all variations of Ubuntu 16.04 LTS Xenial Xerus 64 bit. Do not use the 32 Bit version.

Also, PAY CLOSE ATTENTION when to use "sudo" and when to not. It can cause unexpected issues if you do something as root that you shouldn't.

Much thanks goes out to Google, ProTekk, Canonical, and everyone else that I read a random paragraph here and snippet there.

Ready to begin?

1) Unless it's a completely fresh Ubuntu installation, many people might have the wrong version of Java installed. Let's fix that first.

The command below makes sure you're starting with a clean slate. Copy and paste it into a terminal (command prompt) window:

sudo apt-get remove openjdk-* icedtea-* icedtea6-*

If necessary, follow the on-screen instructions to remove any stray Java versions. Otherwise, move on to the next step.

2) Install the main build tools with this command:

sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven libc6-dev linux-libc-dev gcc-multilib g++-5-multilib libssl-dev

3) "repo" communicates with git servers for all that precious source code. The next command will grab it:

mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

4) Use your favorite text editor to open ~/.bashrc - I like nano:

nano ~/.bashrc

5) At the very bottom (use the Page Down key) paste this code to a new line:

export PATH=~/bin:$PATH
export USE_CCACHE=1

6) Save it. In nano that would be Ctrl-O and then Enter. Then Ctrl-X to exit back to a prompt. Restart bash:

source ~/.bashrc

7) In the terminal, navigate to where you would like to download the Android source code. The commands below will make it in your home folder, but if you have limited space you may want to create it somewhere else. Faster is better, i.e. SSD would be best, USB external (even 3.0) will be comparatively slow. Here we go:

mkdir ~/android
cd ~/android

8) Now you're going to initialize the repo. This is where you decide the flavor of Android you want to build, i.e. AOKP, CyanogenMod, AOSP etc.

For the purposes of this tutorial, here's the command for Cyanogenmod 13 (Marshmallow) :

repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0

9) Time to get the source, many gigabytes of downloading await.

Don't worry, it's automated. It's the last one!

repo sync

Check back periodically every hour or so. It all depends on how fast your connection is.

10) Now, for Java. Some ROMs (Android Lollipop / CM 12.1 and below) require OpenJDK 7. Marshmallow / CM 13 and above require OpenJDK 8. If you're building for reallllllly old devices, OpenJDK 6. Here's the easiest way to install on Ubuntu 16.04.

First, add the PPA for OpenJDK:

sudo add-apt-repository ppa:openjdk-r/ppa

Then, install the appropriate version of Java. In this case we're going to use 7, because it's popular. Simply replace openjdk-7-jdk with 6 or 8 as needed.

sudo apt-get update && sudo apt-get install openjdk-7-jdk

That's it! Everything should be ready to go.

If this guide helped you out, feel free to click the Thanks! button or donate to the new hardware fund​