Post Reply

[Guide] How to build from Android Source Code

OP Furrydaus

2nd January 2015, 01:38 PM   |  #1  


Bare Minimum PC System Requirements:
CPU: Dual Core Intel® Pentium® Processor T4000
RAM: 4GB RAM
Storage: 70GB HDD
OS: Ubuntu 12.02 (Or any variant)
Network Speed: 2MBps

Recommended PC System Requirements:
CPU: Quad Core Intel® I5-3570 Processor
RAM: 8GB RAM
Storage: 200GB SSD
OS: Lubuntu 14.04 LTS (Or any variant)
Network Speed: 15MBps

Why do you need to be in the system requirements range?
Quote:

> The system requirements are the bare minimum you need to have to build efficiently. Anything lower than the bare minimum will take the build more than 1 Day.
> We recommend utilizing SSDs as they are the most efficient at building due to its digital format rather than the traditional HDDs where it utilizes a spinning data disc.
> We recommend a network speed of 2MBps or more due to the size of android source code being more than 10GB of data. Anything lower will take you forever to download and may put you in a risk of data corruption.
> We recommend utilizing Higher Capacity SSDs as building android uses a lot of RAM and having more of this is handy when building.
We recommend utilizing CPUs with more cores as it helps the build process to be faster.
> We recommend using Ubuntu as it is the base standard for building Android ROMs. Any other ubuntu based distros should work with building Android.

Understanding different terms
Quote:

> GIT
Git can be considered as a project planner for code. It is a requirement to learn Git. To learn git, follow this guide.
> REPO
REPO is a tool built by Google to work with GIT to download multiple repositories to your PC.
> Repositories
A repository can be considered as a container for a set of related code.
> Source Code
Source Code is made up of files that instructs different scripts to run to build a certain product specified. The rest of the source code is the resources needed to achieve this.
> CCache
CCache is a method of utilizing a specified storage space to speed up building. It can be considered to be similar as the .odex files you find in Android.
> Terminal
Terminal is a requirement as it will be the 'nerve center' of your Android Building process
> Nano
Nano is the Text Editor for Ubuntu.
> $
The "$" sign in Linux/Ubuntu represents the start of a new line of code. Picture it as a full-stop in a sentence.
> sudo
The term sudo is the way for defining root access in the terminal.

Preparing Ubuntu
Quote:

To build Android, we must install the proper drivers and software. Lets go through this step by step. From now on, anything that is highlighted ORANGE and is not a link will need you to modify it if required.

Installing Git:

Code:
$ sudo apt-get update
$ sudo apt-get install git
$ git config --global user.name Your Name
$ git config --global user.email youremail@googlotmail.com
Installing ADB and Fastboot:
Code:
$ sudo add-apt-repository ppa:phablet-team/tools
$ sudo apt-get update
$ sudo apt-get install android-tools-adb android-tools-fastboot
Installing Building Software:
Code:
$ sudo apt-get install bison g++-multilib git gperf libxml2-utils
Installing Repo:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

Choosing your Source Code
Quote:

To build Android, we must choose the Source Code provider. I'll list the one's I can find below:

Syncing Source Code
Quote:

Now after choosing the Source Code you want, let's head over and prepare the repo to download their source code to your PC. Remember, URL for initializing the repo is always different so you'll need to refer and read the guide shown in their individual mini guides in the links shown above. For this moment, I'll be utilizing the source code found from Resurrection Remix.

Preparing REPO and initialize file directories

Code:
$ mkdir ~/android
$ cd ~/android
$ $  repo init -u https://github.com/ResurrectionRemix/platform_manifest.git -b lollipop
Modifying repo to download source for our device
If you're reading this but don't want to build for Huashan, consult your respective developers at your device's xda forum
Code:
$ cd ~/android/.repo
$ git clone https://github.com/Ultrax5/local_manifests.git
$ cd ~/android
Downloading Source Code
This will take a VERY long time and I probably recommend you go and do other entertaining things while this goes on.
Code:
$ cd ~/android
$ repo sync -j8

Applying the necessary patches
Quote:

For other devices, this will not be needed unless the developer states that a patch is required.

Code:
$ cd ~/android/device/sony/huashan/patches
$ chmod 755 apply.sh
$ ./apply.sh

Building Android
Quote:

Now to the most important part of the guide, BUILDING! If your PC hits the minimum requirements then it will build for about 4-6Hours while if your PC hits the Optimal Recommended Requirements, the build will take about 1Hour.

Obtaining Pre-Builts from CyanogenMod
Only use this if you choose a source that was based off CyanogenMod

Code:
$ cd ~/android/vendor/cm
$ ./get-prebuilts
Building Android
Change Huashan to your device code-name if you're building for other devices. It is recommended to take a look at the output as it may pin-point errors as they pop up.
Code:
$ cd ~/android
$ . build/envsetup.sh
$ brunch huashan

Obtaining the Final Product
Quote:

Congratulations on making it this far! Once the build process is completed with no errors do the following;

> Open up the file manager app of your choice
> Navigate to this directory; ~/android/out/product/huashan/theromzipwilllooklikethis_1242142132.zip

Once you've located the zip file, rejoice! You've successfully built a ROM direct from source! Now, you can flash the zip using your recovery and maybe even post it on XDA!

Epilogue
Quote:

Thank you for following and reading the guide! If you post a ROM by using this guide, please do leave a credit for me and for those who didn't, leave a Thanks!

If you're ever wondering what my Build Environment is like, here's a look at my specs.

PC TYPE: Custom Desktop
CPU: Intel I5 4670k
RAM: CORSAIR Vengeance 8GB
Storage: WD Black² Dual Drive
GPU: Asus GForce GTX 780 [Unimportant in Building]
Motherboard: ASRock 990FX Extreme9
PSU: RM Series™ RM1000
Casing: Cooler Master Cosmos II

[Yes I know, this build might be overkill but who cares :P]

Credits
  1. NexusPrime
  2. MrSteve555
  3. Pec0ra
  4. Other XSP Developers
  5. XDA Developers
  6. Cyanogenmod Build Guides
  7. Resurrection Remix Team
Last edited by Furrydaus; 2nd January 2015 at 01:46 PM.
The Following 24 Users Say Thank You to Furrydaus For This Useful Post: [ View ]
2nd January 2015, 02:12 PM   |  #2  
Member
Flag Paris
Thanks Meter: 17
 
87 posts
Join Date:Joined: Nov 2013
More
@Furrydaus
When I want to patch, i have this error :

./apply.sh
applying hardware_qcom_display-caf to hardware/qcom/display-caf
fatal: Not a git repository (or any of the parent directories): .git
Last edited by Jermin94; 2nd January 2015 at 03:10 PM.
2nd January 2015, 03:14 PM   |  #3  
DjowBr's Avatar
Senior Member
Flag Santos, São Paulo
Thanks Meter: 43
 
251 posts
Join Date:Joined: Dec 2010
More
Since u put the specs for a build PC, im buying some hw and making my pc (sorry for por english). It will be like:
AMD FX6300
Corsair Vengance 8gb 1600
Corsair CX500 psu
And not sure about HD or SSD cause its costs here on Brazil, it will be a mid-top PC and thinking to build to 2 phones... I'll use it for personal and learning Android dev

Sent from my Xperia SP using XDA Free mobile app
2nd January 2015, 03:57 PM   |  #4  
asanan1's Avatar
Member
Flag Nakhon Ratchasima
Thanks Meter: 14
 
37 posts
Join Date:Joined: Mar 2014
Donate to Me
More
Quote:
Originally Posted by Jermin94

@Furrydaus
When I want to patch, i have this error :

./apply.sh
applying hardware_qcom_display-caf to hardware/qcom/display-caf
fatal: Not a git repository (or any of the parent directories): .git

Open apply.sh and Replace With This

Quote:

#!/bin/sh

MYABSPATH=$(readlink -f "$0")
PATCHBASE=$(dirname "$MYABSPATH")
CMBASE=$(readlink -f "$PATCHBASE/../../../../")

for i in $(find "$PATCHBASE"/* -type d); do
PATCHNAME=$(basename "$i")
PATCHTARGET=$PATCHNAME
for i in $(seq 4); do
PATCHTARGET=$(echo $PATCHTARGET | sed 's/_/\//')
if [ -d "$CMBASE/$PATCHTARGET" ]; then break; fi
done
echo applying $PATCHNAME to $PATCHTARGET
cd "$CMBASE/$PATCHTARGET" || exit 1
done

The Following 2 Users Say Thank You to asanan1 For This Useful Post: [ View ]
2nd January 2015, 04:10 PM   |  #5  
Quote:
Originally Posted by DjowBr

Since u put the specs for a build PC, im buying some hw and making my pc (sorry for por english). It will be like:
AMD FX6300
Corsair Vengance 8gb 1600
Corsair CX500 psu
And not sure about HD or SSD cause its costs here on Brazil, it will be a mid-top PC and thinking to build to 2 phones... I'll use it for personal and learning Android dev

Sent from my Xperia SP using XDA Free mobile app

Buy a 250++gb ssd, switch the corsair ram for something cheaper, switch and fx to Intel's i5-3570 and increase psu to 800watt if possible
The Following User Says Thank You to Furrydaus For This Useful Post: [ View ]
2nd January 2015, 04:12 PM   |  #6  
Member
Flag Paris
Thanks Meter: 17
 
87 posts
Join Date:Joined: Nov 2013
More
Ok now it's good.
But when i want to get-prebuilds it said that :

Quote:

bash: ./get-prebuilts: No files or folders of this type

and when i want to re-sync the source i have that :

Quote:

fatal: duplicate path hardware/sony/DASH in /home/jerome/android/system/.repo/manifest.xml

Last edited by Jermin94; 2nd January 2015 at 04:54 PM.
The Following User Says Thank You to Jermin94 For This Useful Post: [ View ]
2nd January 2015, 05:22 PM   |  #7  
asanan1's Avatar
Member
Flag Nakhon Ratchasima
Thanks Meter: 14
 
37 posts
Join Date:Joined: Mar 2014
Donate to Me
More
Quote:
Originally Posted by Jermin94

Ok now it's good.
But when i want to get-prebuilds it said that :



and when i want to re-sync the source i have that :

please check roomservice.xml
2nd January 2015, 05:28 PM   |  #8  
Member
Flag Paris
Thanks Meter: 17
 
87 posts
Join Date:Joined: Nov 2013
More
Quote:
Originally Posted by asanan1

please check roomservice.xml

where is this file ?
2nd January 2015, 05:33 PM   |  #9  
Quote:
Originally Posted by Jermin94


where is this file ?

~/android/.repo/local_manifests/room service.xml

It should be there if you're following my guide. Replace the unneeded repos from there
The Following User Says Thank You to Furrydaus For This Useful Post: [ View ]
2nd January 2015, 05:49 PM   |  #10  
Member
Flag Paris
Thanks Meter: 17
 
87 posts
Join Date:Joined: Nov 2013
More
Ok now it's good it's re-sync the source !

---------- Post added at 05:49 PM ---------- Previous post was at 05:36 PM ----------

When i sync source or want to build a new rom, lines of roomservice.xml are add so I can't build the rom.
Last edited by Jermin94; 2nd January 2015 at 05:40 PM.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes