Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,730,130 Members 53,557 Now Online
XDA Developers Android and Mobile Development Forum

[Guide] In-Depth Compiling using Ubuntu 12.10

Tip us?
 
dragonstalker
Old
(Last edited by dragonstalker; 1st December 2012 at 09:26 PM.)
#1  
dragonstalker's Avatar
Recognized Contributor - OP
Thanks Meter 1220
Posts: 1,805
Join Date: Jan 2008
Location: Grovetown, Ga

 
DONATE TO ME
Default [Guide] In-Depth Compiling using Ubuntu 12.10

DISCLAIMER: I am in no way responsible for you breaking your phone or your computer. You the reader/user/dev/compiler understand that you enter into this agreement freely with no expectations that everything will work 100% of the time.

This is in no way a means of stealing people away from Shrikes guide. If you do not have ubuntu installed as a complete os/ or do not intend to maked modifications to system files etc. Then please use the guide for compiling roms using a virtual box here (CM9 The complete noobs guide to building CM9 in a virtual machine)

Still with me. COOL. So you now have either a dual boot or a fully thrashed Linux machine. I will be using my Vaio VPCF114 box with Ubuntu 12.10 to make this guide. This is also compatible with 12.04 if you have not yet upgraded. I am not sure if the same goes for Redhat/Fedora or Backtrack 5. My work here is a compilation of years of doing research and compiling my own roms.

This guide is to help people that have little knowledge of linux get a base idea of where to start to make their own roms and kernels. Part 1 will be building your box and compiling a rom. Part 2 will be how to make and grab your Kernel.

First lets get Dropbox from here DROPBOX This is good for backing up your libs and sharing files with other Devs.


What you need:
1) A Windows computer, preferably with a CPU that supports 64-bit. Your pc/laptop does no need to have 64-bit windows on it, your CPU just needs to support the hardware. I think at this day and age, almost all devs have a 64-bit box. You will need this so you can make a dual boot box.
2) Plenty of memory. I recommend at least 4GB on the host computer. You can make it work on less, but more is better.
3) At least 60GB of free hard drive space during the install, but i'm sure you already know that and have gigs upon gigs of free space. If you do not know how much space you have, go to settings>details and it will tell you. Note: The source download is approximately 8.5GB in size. You will need over 30GB free to complete a single build, and up to 100GB (or more) for a full set of builds.
4) Lastly a good book, tab, second pc, whatever because this is not a quick process. And compiling roms literally takes hours.
5) Most importantly UBUNTU 12.10. If on the off hand you do not have it, you can pick it up at Ubuntu Central


OK YOU READY. LET'S GET CRACKING. First you need to set up Java on your box. Then grab a couple of programs you will need for editing files Go to your UBUNTU SOFTWARE CENTER. In the search bar in the top right type in Java. We will be installing Java 6 Runtimes.




The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, go here JAVA
If the link does not work, you want accept the license agreement and download jdk-6u35-linux-x64.bin
Once it done:

chmod a+x ~/Downloads/jdk-6u35-linux-x64.bin
sudo mv ~/Downloads/jdk-6u35-linux-x64.bin /usr/lib
cd /usr/lib
sudo ./jdk-6u35-linux-x64.bin


Now lets finish the install and make it default: (Remember to enter in the lines one at a time)

sudo mv jdk1.6.0_35/ jvm/
sudo rm jdk-6u35-linux-x64.bin
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_35/jre/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_35/bin/javac 1
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.6.0_35/bin/jar 1
sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.6.0_35/bin/javadoc 1


IF YOU HAVE MULTIPLE JAVA JDK'S INSTALLED FOR OTHER PROJECTS YOU WILL WANT TO MAKE 1.6 THE DEFAULT.

On each command you will have to select the version of java you want to use. This command is helpful if you also do other coding.

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config jar
sudo update-alternatives --config javadoc




Java 6: for Gingerbread and newer

Java 5: for Froyo and older


Note: The lunch command in the build step will ensure that the Sun JDK is used instead of any previously installed JDK.


Now what we need:

We need to open up a terminal window and download packages.
Remember you will need to input your password after each line.

sudo add-apt-repository ppa:git-core/ppa
and
sudo apt-get update


(this will download all of the Quantal updates for universe and multiverse.


Next we want to install some Libs and Binaries. (You can copy and paste this into your terminal)

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 schedtool gcc-multilib g++-multilib pngcrush

(don't worry. some of the libs my fail. This happens as google changes their sources)

Now we need to tell the computer how to "REPO", this is where you will tell it to handle the Andorid sources via the Git command.

cd ~
mkdir -p bin
export PATH=${PATH}:~/bin


Once done you can use "echo $PATH" to see all of your path directories.

sudo apt-get install curl
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

(this will get you the repo script)

Now lets give it executable permissions by using chmod

chmod a+x ~/bin/repo


Now that we can repo



Lets setup the Android SDK. (Get a beer/coffee/soda, this will take a second)

Go to http://developer.android.com/sdk/index.html And install the ADT bundle for Linux.

Install the SDK and Eclipse IDE

Unpack the ZIP file (named adt-bundle-linux.zip) and save it to an appropriate location, such as a "Development" directory in your home directory.
Open the adt-bundle-linux/eclipse/ directory and launch eclipse.
That's it! The IDE is already loaded with the Android Developer Tools plugin and the SDK is ready to go. To start developing, read Building Your First App on the developer site.



Caution: Do not move any of the files or directories from the adt-bundle-linux directory. If you move the eclipse or sdk directory, ADT will not be able to locate the SDK and you'll need to manually update the ADT preferences.

Now to just add the tools to our $Path.

gedit .bashrc
Scroll to very bottom, under last fi input
export PATH=${PATH}:~/adt-bundle-linux/sdk/tools
export PATH=${PATH}:~/adt-bundle-linux/sdk/platform-tools


That was pretty painless.

Now lets start some cool stuff.

TestSigning

Click on your desktop menu bar and go into your home folder. Press Ctrl and h together on your keyboard to show hidden folders. Anything marked with a . in front of it is hidden, we are looking for a folder name .gnome2, go into it and look for nautilus-scripts. Once inside this folder, right click on a empty space and select create document and then empty file and name it sign. Open up that empty document and copy and paste this script from dumbfaq on xda



Code:
#!/bin/bash

# Update the Loc var to where YOU stored the testsign.jar file !



SUCCESS=

Loc=~/android/source/



for arg

do

TMP=$(ls $arg | sed 's/\(.*\)\..*/\1/')

EXT=${arg##*.}



java -classpath "$Loc"testsign.jar testsign "$arg" "$arg"-signed 2> /tmp/signTmp

SUCCESS=$?

if [ $SUCCESS -eq 1 ]

then

zenity --info --title "Sign APK" --text "signing FAILED! \n`cat /tmp/signTmp`"

exit 1

fi



mv $TMP.$EXT-signed $TMP-signed.$EXT

done



zenity --info --title "Sign APK" --text "signing completed!"
Save and exit out and right click on our new script and select properties. select the permissions tab and look for a check box that says allow executing as a program. click on it and now we have a pretty little script that we can just right click on a update.zip file and sign with our test keys for flashing. You will also need the testsign.jar from the bottom of this guide.



Now lets do a couple things so that we can get our Phones Vendor ID.

Type in your terminal

lsusb

While your phone isconnected to see our vendor id and you will something like this. Note that for the Rezound our vendor id is

Bus 002 Device 003: ID 0bb4:0ccd HTC (High Tech Computer Corp.)
In this case the Vendor Id is “18d1″ and the Product ID is “4e12″. Please keep in mind that the Vendor ID for HTC changed from “0bb4″ to “18d1″. The older HTC phones like the G1 have a Vendor ID of “0bb4″.



Now that we have that, we can make our rules for for connecting to adb

sudo gedit /etc/udev/rules.d/51-android.rules

Paste

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev"

Save and exit



Reboot your computer so that all of the changes we have made can Take effect.



OK. All setup and ready to start making a Rom with your name on it.

IF you are already running AOSP on your phone, you can back up you system now Do this by:

cd ~/
mkdir stock
cd stock
adb pull /system/ ~/stock/


This will dump your entire system directory into the stock folder. This is good so you always have a working system. Now zip the folder and tuck it away for safe keeping.


Now the MEAT AND POTATOES. Grabbing the Source. "CYANOGENMOD"

cd ~/
mkdir -p android/source
touch ~/.netrc
cd ~/android/source
sudo apt-get install git
sudo sysctl -w net.ipv4.tcp_window_scaling=0 (remvoes the overstack flow problem that causes some repo jobs to hang)
repo init -u git://github.com/Chad0989/android.git -b ics

(Note: If you want to compile a jellybean rom, just replace the ics with jellybean!)

Once you do this, it's going to ask you for your email. This is how you will log back into the repo in the future. So answer the questions correctly.



Now we will sync the Repo and set it to run.

repo sync -j4

-j# (# means twice the amount of cores in your computer) means jobs. I have an i7 processor and a pretty decent internet connection, so i'm running max jobs at once for faster sync) Be patient. It's still going to take a while to clone the directory.


Once done with the Sync we want to setup our device.

This is where we get the pre-built part of our rom.

First we will
./vendor/cm/get-prebuilts

Probably all that will be left directly after the repo will be the Terminal service for android.

Now we are about ready to compile our Rom:

cd ~/android/source
repo sync (it should only take a moment this time)
. build/envsetup.sh
make clobber





Now you can compile your rom using the brunch command (This will take about 1 to 1 1/2 hours depending on your box)

brunch vigor

Now you can go to the output box and pick up your freshly made Rom.
Attached Files
File Type: jar testsign.jar - [Click for QR Code] (12.7 KB, 77 views)
 
--HTC One (M*8)
--Note 10.1 2k4
-Recovery: TWRP
-Recovery: TWRP
-OS: Android 4.4.2
-OS: Android 4.4.2
-ROM: NV M8 RLS2
-ROM: xKat V3.2
-Kernel: ?
-Kernel: Bindroid V3



Blog: MobileEscape.blogspot.com

Retired: Behold, G1, MT Fender, MT3G Slide, Vibrant, N1, HD2 (android-Froyo), Viewsonic G-Tablet, AT&T SE Xperia X10i, Samsung Galaxy Tab; HTC Inspire, HTC Sensation, Droid Charge, MYTOUCH4G , Thunderbolt, Droid DNA (traded), Note 2, HTC Rezound, Note 3 (jumped)
The Following 13 Users Say Thank You to dragonstalker For This Useful Post: [ Click to Expand ]
 
dragonstalker
Old
#2  
dragonstalker's Avatar
Recognized Contributor - OP
Thanks Meter 1220
Posts: 1,805
Join Date: Jan 2008
Location: Grovetown, Ga

 
DONATE TO ME
Reserved for Kernel
 
--HTC One (M*8)
--Note 10.1 2k4
-Recovery: TWRP
-Recovery: TWRP
-OS: Android 4.4.2
-OS: Android 4.4.2
-ROM: NV M8 RLS2
-ROM: xKat V3.2
-Kernel: ?
-Kernel: Bindroid V3



Blog: MobileEscape.blogspot.com

Retired: Behold, G1, MT Fender, MT3G Slide, Vibrant, N1, HD2 (android-Froyo), Viewsonic G-Tablet, AT&T SE Xperia X10i, Samsung Galaxy Tab; HTC Inspire, HTC Sensation, Droid Charge, MYTOUCH4G , Thunderbolt, Droid DNA (traded), Note 2, HTC Rezound, Note 3 (jumped)
The Following 3 Users Say Thank You to dragonstalker For This Useful Post: [ Click to Expand ]
 
dragonstalker
Old
(Last edited by dragonstalker; 17th March 2013 at 06:11 PM.)
#3  
dragonstalker's Avatar
Recognized Contributor - OP
Thanks Meter 1220
Posts: 1,805
Join Date: Jan 2008
Location: Grovetown, Ga

 
DONATE TO ME
Changed Repo from CyanogenMod to Chad0989 for easier Vigor integration.
21NOV12: Change Repo from Chad0989 to Dragonstalker github.

Change Repo from DragonStalker to Chad0989 github

Modified Testsign script to reflect changed ADT Tools location.
 
--HTC One (M*8)
--Note 10.1 2k4
-Recovery: TWRP
-Recovery: TWRP
-OS: Android 4.4.2
-OS: Android 4.4.2
-ROM: NV M8 RLS2
-ROM: xKat V3.2
-Kernel: ?
-Kernel: Bindroid V3



Blog: MobileEscape.blogspot.com

Retired: Behold, G1, MT Fender, MT3G Slide, Vibrant, N1, HD2 (android-Froyo), Viewsonic G-Tablet, AT&T SE Xperia X10i, Samsung Galaxy Tab; HTC Inspire, HTC Sensation, Droid Charge, MYTOUCH4G , Thunderbolt, Droid DNA (traded), Note 2, HTC Rezound, Note 3 (jumped)
The Following User Says Thank You to dragonstalker For This Useful Post: [ Click to Expand ]
 
jon7701
Old
#4  
Senior Member
Thanks Meter 159
Posts: 515
Join Date: Aug 2012
Location: Storm Lake

 
DONATE TO ME
First, looks interesting i might look into this when i boot into Ubuntu next time.
Current Phone: HTC Rezound(Vigor) S-OFF!!
Rom: Carbon 4.4.2 || Kernel: Stock 4.4, Undervolted -100mV || Hboot: Stock 2.28
Radios: 2.23.10.0123r, 2.23.10.0124r || Recovery: TWRP 2.6.3.0

Current Tablet: Tegra Note 7
Rom: Stock 4.4.2 || Kernel: Stock Kernel || Recovery: CWM 6.0.4.6

If i help you in anyway please remember to hit that Thanks button.
 
dragonstalker
Old
#5  
dragonstalker's Avatar
Recognized Contributor - OP
Thanks Meter 1220
Posts: 1,805
Join Date: Jan 2008
Location: Grovetown, Ga

 
DONATE TO ME
Quote:
Originally Posted by jon7701 View Post
First, looks interesting i might look into this when i boot into Ubuntu next time.
i wanted to show people how i do my own personal roms and kernels. With this setup, you can make roms for multiple devices and also use Eclipse to make apps if thats your bag baby.
 
--HTC One (M*8)
--Note 10.1 2k4
-Recovery: TWRP
-Recovery: TWRP
-OS: Android 4.4.2
-OS: Android 4.4.2
-ROM: NV M8 RLS2
-ROM: xKat V3.2
-Kernel: ?
-Kernel: Bindroid V3



Blog: MobileEscape.blogspot.com

Retired: Behold, G1, MT Fender, MT3G Slide, Vibrant, N1, HD2 (android-Froyo), Viewsonic G-Tablet, AT&T SE Xperia X10i, Samsung Galaxy Tab; HTC Inspire, HTC Sensation, Droid Charge, MYTOUCH4G , Thunderbolt, Droid DNA (traded), Note 2, HTC Rezound, Note 3 (jumped)
The Following 2 Users Say Thank You to dragonstalker For This Useful Post: [ Click to Expand ]
 
jon7701
Old
#6  
Senior Member
Thanks Meter 159
Posts: 515
Join Date: Aug 2012
Location: Storm Lake

 
DONATE TO ME
Quote:
Originally Posted by dragonstalker View Post
i wanted to show people how i do my own personal roms and kernels. With this setup, you can make roms for multiple devices and also use Eclipse to make apps if thats your bag baby.
Nice, if i can figure out a little more about how to dev and stuff maybe ill make my own rom one day.
Current Phone: HTC Rezound(Vigor) S-OFF!!
Rom: Carbon 4.4.2 || Kernel: Stock 4.4, Undervolted -100mV || Hboot: Stock 2.28
Radios: 2.23.10.0123r, 2.23.10.0124r || Recovery: TWRP 2.6.3.0

Current Tablet: Tegra Note 7
Rom: Stock 4.4.2 || Kernel: Stock Kernel || Recovery: CWM 6.0.4.6

If i help you in anyway please remember to hit that Thanks button.
The Following User Says Thank You to jon7701 For This Useful Post: [ Click to Expand ]
 
vonhinkle
Old
#7  
Senior Member
Thanks Meter 37
Posts: 262
Join Date: Nov 2010
Location: Grand Rapids, MI
Wow. So going to do this right now. Thanks for your effort on this.

Sent from my ADR6425LVW using xda premium
 
drkow19
Old
#8  
Senior Member
Thanks Meter 76
Posts: 419
Join Date: Apr 2009
Location: Auburn Hills, Michigan
I can't wait for the final act! I am going to try this so I can get my hands on some jelly beans.
 
vonhinkle
Old
#9  
Senior Member
Thanks Meter 37
Posts: 262
Join Date: Nov 2010
Location: Grand Rapids, MI
Default Vedor ID

Quick question. I notice that you mention that "in this case the Vedor ID is 18d1" but in your screenshot it say 0bb4. You have some clarification after that and I'm not sure I understand it 100%. My rezound show the 0bb4 for vedor ID as well. I guess what I'm asking is if you could clarify the statement about the Vendor ID? Thanks, sorry if this is a dumb question.
 
GrayTheWolf
Old
#10  
GrayTheWolf's Avatar
Senior Member
Thanks Meter 2125
Posts: 4,955
Join Date: Mar 2012
Location: Raleigh, NC

 
DONATE TO ME
Very nice guide. Extremely thorough which makes a great tutorial.
S-Off thanks to Beaups and Sonic2756!


If I helped in any way, please hit the "Thanks" button!

Click here to check out my development page.

The Following User Says Thank You to GrayTheWolf For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes