[HOW TO] Setup Ubuntu 15.04 Vivid Vervet to Compile Android ROMs

— 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 world-famous guide for setting up a build environment to compile Android ROMs. The aim of this is to simplify the configuration process for you.

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

This guide applies to all variations of Ubuntu 15.04 Vivid Vervet 64 bit. Do not use the 32 Bit version.

Also, PAY CLOSE ATTENTION when to use “sudo” and when to not. It can make things funky 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? Ok.

1) Unless it’s a completely fresh Ubuntu installation, many of you 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 openjdk-7-jdk git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 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

That’s it on the package side of things.

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 the tutorial, here’s the command for SimpleAOSP Lollipop:

repo init -u https://github.com/SimpleAOSP-Lollipop/platform_manifest.git -b L

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

Don’t worry, it’s automated.

Hey everyone, it’s the final terminal command!

repo sync

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

That should be everything. Now you are ready to build Android. Good luck!

If this guide helped you out, feel free to buy me a coconut water (donate). It would be greatly appreciated!

If you want to build Gingerbread thru KitKat, here’s the easiest way to change Java versions:

First add the PPA for older Java 1.6 builds.

sudo add-apt-repository ppa:webupd8team/java

Then install:

sudo apt-get update && sudo apt-get install oracle-java6-installer

Once that completes, you simply need to tell Linux to use the older version of Java and Java Compiler to render content.

Run the following two commands separately, making the correct selection for Oracle JDK 1.6 both times when prompted. Again in the terminal:

sudo update-alternatives --config java
sudo update-alternatives --config javac

That should do the trick!

10 comments

  1. I had your 1.5 pre built. on 14.04 ubuntu.

    Now ia installed an ssd and new fresh win 10.
    I cant get this back to work. tried to use your older builds without any luck.
    Can you help me?

  2. Nathan, I get the following message when attempting a make of a Lollipop ROM:
    ============================================
    PLATFORM_VERSION_CODENAME=REL
    PLATFORM_VERSION=5.0
    TARGET_PRODUCT=anzhen4_mrd7_64
    TARGET_BUILD_VARIANT=userdebug
    TARGET_BUILD_TYPE=release
    TARGET_BUILD_APPS=
    TARGET_ARCH=x86
    TARGET_ARCH_VARIANT=silvermont
    TARGET_CPU_VARIANT=x86
    TARGET_2ND_ARCH=
    TARGET_2ND_ARCH_VARIANT=
    TARGET_2ND_CPU_VARIANT=
    HOST_ARCH=x86_64
    HOST_OS=linux
    HOST_OS_EXTRA=Linux-3.19.0-28-generic-x86_64-with-Ubuntu-15.04-vivid
    HOST_BUILD_TYPE=release
    BUILD_ID=LRX21V
    OUT_DIR=out
    ============================================
    Checking build tools versions…
    ************************************************************
    You are attempting to build with the incorrect version
    of java.

    Your version is: Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar java version “1.7.0_79” OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.15.04.1) OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode).
    The required version is: “1.7.x”

    Please follow the machine setup instructions at
    https://source.android.com/source/initializing.html
    ************************************************************
    build/core/main.mk:167: *** stop. Stop.
    make: Leaving directory ‘/home/tecknight/x98/x86-android-5.0’

    #### make failed to build some targets (4 seconds) ####

    tecknight@LenovoTec:~/x98/x86-android-5.0$

    1. it seems like you don’t have java installed or corrupt/wrong version:
      so try:
      sudo apt-get remove openjdk-* icedtea-* icedtea6-*
      sudo apt-get update && sudo apt-get install -y openjdk-7-jdk

  3. First off nice manuel! always good to see this kind of help on the internet.
    A few additions:
    1. you also need phablet-tools to install.
    2. You need to config git: git config –global user.email “theekilla@*****.com”
    git config –global user.name “theekilla”
    3. you need to set a ccache size: /usr/bin/ccache -M 100G

  4. file /etc/default/local
    LANG=”en_US.UTF-8″ -> LANG=”de_DE.UTF-8″

    sudo apt-get install language-pack-de ?

    sudo apt-get update ?

    sudo apt-get install language-pack-de language-pack-de-base ?

    it does not work?

Leave a comment

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.