Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,811,290 Members 46,529 Now Online
XDA Developers Android and Mobile Development Forum

[ GUIDE ] How to Prepare Ubuntu 14.04 LTS Trusty Tahr to Compile Android ROMs

Tip us?
 
sylentprofet
Old
(Last edited by sylentprofet; 12th September 2014 at 02:09 AM.)
#1  
Senior Member - OP
Thanks Meter 1,327
Posts: 203
Join Date: Jun 2010
Location: Sacramento

 
DONATE TO ME
Tutorial [ GUIDE ] How to Prepare Ubuntu 14.04 LTS Trusty Tahr to Compile Android ROMs

--- If you would rather use a ready-to-go Virtual Machine, check out my post here. ---
--- Copied with permission from http://nathanpfry.com ---

TLDR; if you don't care about an explanation of what your system is doing,
click here to check out XDA Senior Member Aaahh's sweet two-step method based on my guide below.
Otherwise, keep reading!


With a new version of Ubuntu comes an update to my world-famous guide for setting up a build environment to compile Android ROMs. 14.04 Trusty Tahr is the next Long Term Support edition of the popular Linux distro. The aim of this guide 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 sections in order and you will be up and running in no time!

This guide applies to all variations of Ubuntu 14.04 LTS Trusty Tahr 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 may 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:

Code:
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
If necessary, follow the on-screen instructions to remove any previous versions. Otherwise, move on to the next step.

It's time to install Java, one of the core pieces for compiling Android ROMs. Depending on which version of Android you are building, you will need the corresponding version of the Java Development Kit.

*** IF YOU ARE BUILDING ANDROID GINGERBREAD THRU KITKAT (2.3 - 4.4.x) USE THESE INSTRUCTIONS FOR JDK 6***
 
2) Copy and paste the following into the terminal:

Code:
sudo add-apt-repository ppa:webupd8team/java
This will add the correct PPA to your system for updated builds of Java 6 JDK that are compatible with 14.04.

3) Now you need to install the package. More copy-paste:

Code:
sudo apt-get update && sudo apt-get install oracle-java6-installer
Follow the on-screen instructions. You must accept the Licensing Agreement to complete the install.

Press Enter to acknowledge the "OK", then tab over to "Yes" and press Enter again to accept the license. The installation will continue automatically.

4) Let's make sure the correct version of Java is activated. Run the terminal command:

Code:
java -version
You should see something like:

java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Continue to Step 5.


*** IF YOU ARE BUILDING ANDROID L AND ABOVE (CURRENT AOSP MASTER BRANCH) USE THESE INSTRUCTIONS FOR JDK 7***
 
2) Install Open-JDK 7 for the necessary Java development tools.

Code:
sudo apt-get update && sudo apt-get install openjdk-7-jdk
Follow the on-screen instructions.

3) Let's make sure the correct version of Java is activated. Run the terminal command:

Code:
java -version
You should see something like OpenJDK 1.7

Continue on to Step 5.


5) Back to a fresh terminal prompt. Install the main build tools with this command:

Code:
sudo apt-get install git gnupg ccache lzop flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z1-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev squashfs-tools pngcrush schedtool dpkg-dev
6) When those are done installing, run the next line in your terminal window:

Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
That's it on the package side of things. You guessed it, time for more Terminal. This really is the easiest way, I promise.

7) A program called "repo" lets you communicate with git servers and download all that precious source code. The next command will install it:

Code:
mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo
8) Use your favorite text editor to open ~/.bashrc - I like nano:

Code:
sudo nano ~/.bashrc
9) At the very bottom (use the Page Down key) paste this code to a new (empty) line:

Code:
export PATH=~/bin:$PATH
10) Save it. In nano that would be Ctrl-O and then Enter. Then Ctrl-X to exit back to a prompt. Restart bash:

Code:
source ~/.bashrc
11) 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 is basically unusable. Here we go:

Code:
mkdir ~/android
cd ~/android
12) 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 AOKP KitKat:

Code:
repo init -u git://github.com/AOKP/platform_manifest.git -b kitkat
13) Almost there. Last step, it's a doozy. Time to get the source. Prepare yourself, 10+ GB of downloading await.

Don't worry, it's automated. Go to sleep. Eat something. Perhaps you have heard of this new thing the kids are doing called "going outside"? Yeah, I didn't think so. Me neither.

Hey everyone, it's the final terminal command:

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

That should be everything. Now you're ready to build Android the right way. Good luck!

Feel free to buy me a coconut water (donate) if you like my work. It would be greatly appreciated!

Please hit the "Thanks" button if this post helped you out!
e: sylentprofet (at) gmail
gh: github.com/sylentprofet/
b: nathanpfry.com
The Following 97 Users Say Thank You to sylentprofet For This Useful Post: [ Click to Expand ]
 
fgdn17
Old
(Last edited by fgdn17; 8th February 2014 at 08:31 PM.)
#2  
Junior Member
Thanks Meter 2
Posts: 19
Join Date: Dec 2010
Exclamation not for me...

ppa:webupd8team/java no longer supports oracle-java6-installer.....

at least when I tried it on ubuntu 14.04 a week ago......

had to resort to the old fashion way of installing jdk from older oracle instructions...!!!

UPDATED:
----------------
seems at the time we tested(feb.4) it did not work but since then has been fixed...

at the time the OP posted it had been corrected, feb.7
The Following User Says Thank You to fgdn17 For This Useful Post: [ Click to Expand ]
 
sylentprofet
Old
#3  
Senior Member - OP
Thanks Meter 1,327
Posts: 203
Join Date: Jun 2010
Location: Sacramento

 
DONATE TO ME
Quote:
Originally Posted by fgdn17 View Post
had to resort to the old fashion way of installing jdk from older oracle instructions...!!!
Respectfully, you're wrong.

Yesterday I tried the instructions (as I was writing the guide) with the latest Alpha of Xubuntu 14.04 and it works fine.

It appears they've updated the PPA within the last few days to support Trusty Tahr.

I wouldn't publish a guide that I hadn't verified myself as working, unlike some people.
e: sylentprofet (at) gmail
gh: github.com/sylentprofet/
b: nathanpfry.com
The Following 3 Users Say Thank You to sylentprofet For This Useful Post: [ Click to Expand ]
 
fgdn17
Old
(Last edited by fgdn17; 8th February 2014 at 01:48 AM.)
#4  
Junior Member
Thanks Meter 2
Posts: 19
Join Date: Dec 2010
well that implies they have fixed it...because on feb 4 we setup Ubuntu 14.04 and had to work around the issue
because it did not work.....

so did it work well for you a week ago???

maybe because of the different systems???

will give it a try again in the next couple of weeks if we get time...either way it's good to know
it has been corrected....

and BTW we also installed openjava 7, switched between the two and
build our source without issues.....

source was android-x86 kitkat
 
fgdn17
Old
#5  
Junior Member
Thanks Meter 2
Posts: 19
Join Date: Dec 2010
got a chance to check this am and it was FIXED YESTERDAY it appears.....

https://launchpad.net/~webupd8team/+archive/java

https://launchpad.net/~nilarimogard/+related-packages

and as stated did not work a week ago....feb.-1 thru feb 4

thanks for the updates...
 
sylentprofet
Old
#6  
Senior Member - OP
Thanks Meter 1,327
Posts: 203
Join Date: Jun 2010
Location: Sacramento

 
DONATE TO ME
Quote:
Originally Posted by fgdn17 View Post
got a chance to check this am and it was FIXED YESTERDAY it appears.....
That's great, but your first post is still wrong. You should edit it so other users aren't confused.

oracle-java6-installer works perfectly fine in Ubuntu 14.04 at the time of the original posting.
e: sylentprofet (at) gmail
gh: github.com/sylentprofet/
b: nathanpfry.com
 
Aaahh
Old
#7  
Aaahh's Avatar
Senior Member
Thanks Meter 838
Posts: 1,087
Join Date: Nov 2013
I used 14.04 early and i had to install some extra packages because things wouldn't work properly, just a heads up incase anyone is having problems...
 
PabloPL
Old
#8  
Senior Member
Thanks Meter 66
Posts: 102
Join Date: May 2008
I've build android 4.2 and 4.4 using openjdk 1.7, without any changes, using ubuntu 13.10 (some time ago in aosp there has been added patches which fixes build under java 7, of course it's not for all android versions).
 
AdamOutler
Old
#9  
AdamOutler's Avatar
Recognized Developer
Thanks Meter 9,623
Posts: 5,196
Join Date: Feb 2011
Location: Louisiana

 
DONATE TO ME
This guide really complicates things. Most of this could be put into a single one-liner.
Flash with Odin on Windows, Linux and Mac. Use JOdin3, Available in a web browser or offline
Check out my developer pages. Add me to your circles on Google Plus.
Wanna see the longest Linux BASH script ever made? click here.
The Following 2 Users Say Thank You to AdamOutler For This Useful Post: [ Click to Expand ]
 
MJPollard
Old
#10  
MJPollard's Avatar
Senior Member
Thanks Meter 619
Posts: 822
Join Date: Sep 2011
Location: Wixom, Michigan
I appreciate a detailed, step-by-step guide like this. In my experience here, I've found that far too many arrogant developers hold the opinion that since they had to find things out the hard way, everyone else should have to as well. Finding developers that actually want to help people out, rather than snub them with snot-nosed attitudes, is always refreshing, so thanks to the OP for the guide!
MARTIN'S ANDROID DEVICES

Current:
Samsung Galaxy S3 (AT&T) running Quantum v5
Google Nexus 10 running CM 11

Retired:
Asus Eee Pad Transformer TF101
Motorola Atrix 4G

The Following 5 Users Say Thank You to MJPollard For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes