yashsingh1/xdaforums huggingface dataset:
[Android] jackeagle:
Setting Up Build Enviroment For Compiling ROM's

​

Installation of Necessary Tools and packages for ROM Development

1)

Installing Java Development Kit (JDK)

For Kitkat

Installation of Java V6

​

Open The Terminal and Paste following Command

a) This will Remove the wrong Java JDK from Ubuntu 13.10

[COLOR=#000000]sudo apt-get purge openjdk-\* icedtea-\* icedtea6[COLOR=#007700][COLOR=black]-\*[/COLOR] [/COLOR][/COLOR]

b) Enter the Following Command and This will Install JDK

wget https://launchpad.net/~webupd8team/+archive/ubuntu/java/+files/oracle-java6-installer_6u45-0%7Ewebupd8%7E8_all.deb sudo dpkg -i oracle-java6-installer_6u45-0~webupd8~8_all.deb wget https://launchpad.net/~webupd8team/+archive/ubuntu/java/+files/oracle-java6-set-default_6u45-0%7Ewebupd8%7E8_all.deb sudo dpkg -i oracle-java6-set-default_6u45-0~webupd8~8_all.deb

c) Check The Java Version Installed

[COLOR=#000000]java -[COLOR=#0000BB][COLOR=black]version [/COLOR] [/COLOR][/COLOR]

For Lollipop Required Java Version is 7

To Install Java V7

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

:DJava Installation Completes:D

2)

Installation Of Required Tools

Enter The Following Command

sudo apt-get install git-core gnupg ccache lzop flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5 lib32z1 lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc readline-common libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev python

Note : If you get error like broken dependencies then use the following command and then use above command.:D

sudo apt-get update

sudo apt-get upgrade

After Installation Completes Enter The Following Command

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

So The Above Are The Packages

Now comes the binary called Repo.

What Is Repo?:rolleyes:

Repo is a repository management tool that we built on top of Git. Repo unifies the many Git repositories when necessary, does the uploads to our revision control system and automates parts of the Android development workflow.

Enter The Following Command

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

Using Text Editor Open ~/.bashrc for that use following command

sudo nano ~/.bashrc

At The Very Bottom Line Add following Line

export PATH=~/bin:$PATH

Save it. Here To save Press Ctrl+O and Enter and Ctrl+X to exit:)

Now Enter Following Command

source ~/.bashrc

:cool::cool:Now Your System Is Ready For ROM Building:D:D
​
[Android] jackeagle:
Downloading Sources

​

To build a Rom from Source first we need to download the sources from git.

Note : Sources will be very huge approx 13GB to 14GB hence lot of patience is required since it will take some time depending on your Internet connection speed.

So lets start..

Here i will take the example of cm11.

The steps goes has follows

1) Create a directory were your sources will be downloaded. Enter the following command to terminal to create a directory

mkdir cm11

Now in your Home directory you will see folder called cm11.

2) The next step is you have to Initiate the repo. meaning of the repo is given above. It will communicate with the git and download the source were it is stored.

Enter The Following Command to Terminal

cd cm11

This will take you to the directory you created in Step 1.

Now Enter The Following Command Which Will Initiate The Repo :laugh:

[FONT=Arial][SIZE=4]repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0[/SIZE][/FONT]

Since i m taking example of cm11 above repo initiate command is used you can find this here for CM11

Note : All the details for Repo Initiate and Building will be given in respective Source Github. Various Github source links will be given in discription and the end.

This will initialize your local repository using the CyanogenMod trees.:p:D:D

now got to cm11 folder and press Ctrl+H this will show the hidden folder .repo were sources will be downloaded.

Now it might give a small error at the end stating for Email id.

So just create a github account here

Then Run following in Terminal

[FONT=Arial][SIZE=4]git config --global user.email "you@example.com"
git config --global user.name "Your Name"[/SIZE][/FONT]

replace "you@example.com" with your github email Id

replace "Your Name" with github Username

3) Now To control the files that should be downloaded while sync and for adding device tree we use local_manifest.xml. Reagrding this @Kishan14 will explain in detail with Tips and Tricks.

4) Now it is the time to download the sources. for that run the following Command

repo sync -j#

# is number of jobs you want to give for your downloading source. I use 2 to 4.

Now it will download the Sources needed to build the Rom..Download will be huge 13GB to 14GB so be patient since it depends on your Internet Speed.

The Above was for CM11 same procedure for other provided you have to replace cm11 with one you want to sync/build like AOSP,AOKP,AICP etc and Repo Initialize command varies with the source you want to download.

Some Git Links :

CM11 : https://github.com/CyanogenMod/android

AOKP : https://github.com/AOKP/platform_manifest

Carbon Rom : https://github.com/CarbonDev/android

SlimRom : https://github.com/SlimRoms/platform_manifest
[Android] jackeagle:
Frequently Asked Questions

(F.A.Q)

Following are some frequently asked Questions:cowboy::cowboy:

1) Can I Use Different Linux OS like Linux Mint , Arch linux , Ubuntu 14.04 etc ?

Yes. you are free to use any Linux System but remember some commands may not work in other Linux System or can result in error hence i cant give support to it. If it was successful to you in Other Linux OS kindly let me know:)

2) Where is the next part of the Guide?

This Thread Is Still Work In Progress (WIP) hence we are working on it and will be added once done:)

3) I got a error for Task X and solved it. Can i share here?

Yes you can share it with solution (If u have):)

4) I Got a Error Where Should I Post ?

You can copy paste the error from terminal to here using Tag or You can Pastebin it. Whichever you are Comfortable with :)

5) Can I Use 32Bit Linux for Android Development ?

No You need 64bit Linux System For Android Development:)

6) Can I use X Device Tree for Y Device (Cloned Etc) ?

No You Should use your Device Specific Tree not other Device Tree even if they are similar Device/Kernel/Vendor Tree are Specific For Each Devices. So if you dont have it then Either you make your own Tree or wait for developers to do that :)

7) Are Device Specific Sources Android Version Specific ??

Yes Device Specific Sources are Version Specific but modification in Source may be little or huge depending on Android Upgrade Feature/Security Enhancement etc etc ...:)

8) Getting Java Error While Compiling What to do ?

Its due to Wrong Java for Compiling you need right Version of Java Installed for

Kitkat : Java v1.6

Lollipop : Java v1.7

:)

​
[Android] jackeagle:
Some Errors and Their Solution

Set-1 (Thanks [MENTION=4867515]Nikhil[/MENTION])

1) gr_text

the line "note : previous declaration of 'gr_text' was here" says that minui.h has declaration of gr_text which is different from definition of gr_text function.

Solution : check minui.h, 36th line (as intimated in Screenshot) and compare declaration of gr_text with the definition of gr_text in file recovery/graphics.c in device tree. they should be same.

2) hardware ril

this generally happens when hardware/samsung is missing some files.

Solution : enter this in terminal

cd hardware && git clone https://github.com/SlimRoms/hardware_samsung.git -b kk4.4 && mv hardware_samsung samsung

you can use Rom specific github link, SlimRoms is an example.

3) hwc_blit

"'HWC_BLIT' was not declared in this scope". HWC_BLIT is a variable with value 4 and it is required to be declared

Solution : there is a file include/hardware/hwcomposer_defs.h in device tree, you can initialize HWC_BLIT as 4.

4) java version

From Froyo to Kitkat, version of java required is 1.6

From Android L, version of jave required will be 1.7

Screenshot has version 1.8 hence the error.

Solution : Install Java 1.6

//Install JDK6

//Download bin file from http://ghaffarian.net/downloads/Java/JDK/

//To remove existing java package

sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*

//install java JDK6 (download and keep .bin file in root directory.)

sudo mkdir -p /opt/java/64/

sudo cp jdk-6u45-linux-x64.bin /opt/java/64

sudo su -

cd /opt/java/64

chmod +x jdk-6u45-linux-x64.bin

./jdk-6u45-linux-x64.bin

exit

//add JDK path to .bashrc

gksudo gedit ~/.bashrc

//add following lines to .bashrc

# Java PATHs

export JAVA_HOME=/opt/java/64/jdk1.6.0_45

export PATH=$PATH:$JAVA_HOME/bin

//install jre

sudo apt-get install openjdk-6-jre-headless

Set-2

(Thanks@JJsevol)

# Errors you might see when you run the build command.

# Error 1: build/envsetup.sh: line 1365: schedtool: command not found

SOLUTION: sudo apt-get install schedtool﻿ and rerun build command.

# Error 2: /bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: cannot execute binary file

/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: cannot execute binary file

SOLUTION: You're most likely not running a 64-bit linux version. To make sure, type uname -m

If you see i686, you have a 32-bit version. If you see x86_64, you have a 64-bit version. If you have 32-bit start over with a amd64 version http://releases.ubuntu.com/13.10/

# Error 3: If you see a 127 bison error

SOLUTION: sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop openjdk-6-jdk openjdk-6-jre phablet-tools pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev

In addition to the above, do

sudo apt-get install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev

Contributors To The Guide

@jackeagle

@Kishan14

@rutvikrvr

@k2wl

@Trach

Credits :

@k2wl (Thanks A Lot)

XDA Developers

​
[Android] RVR:
How to apply patches to the source ?

There are many devices that need patches for the core functions to work . So in this guide i will be talking about applying patches from github and the Gerrit Code Review HERE AGAIN I WILL BE TAKING I9082 AS AN EXAMPLE

I) APPLYING PATCHES FROM THE GERRIT CODE REVIEW .

NOTE: IF THE ROM YOU ARE COMPILING IS BASED ON CYANOGENMOD AND THE COMMIT IS MERGED ... THEN THE PATCH DOESNT HAVE TO BE APPLIED

this is how a gerrit code review typically looks . To apply a patch from here ...

STEP 1:

You first have to click on patch and then copy the link

STEP 2:

In your terminal navigate to the place it has to be applied (in this case the path is "frameworks/native")

as you can see the command boxed in blue .. it should look somewhat similar

after the patch is applied it asks for an input to continue ... in such a case simply press "q"

CONGRATULATIONS YOU HAVE APPLIED THE PATCH FROM THE GERRIT CODE REVIEW!!!

NOW WE MOVE ON TO APPLYING PATCHES DOWNLOADED FROM GITHUB GISTS

(GENERALLY THE FORMAT IS ".diff" or ".patch")

STEPS TO BE FOLLOWED

STEP1: DOWNLOAD THE GIST

You can simply download the gist as shown in the image below

THIS IS HOW A PATCH TYPICALLY LOOKS

these patches are used generally for unofficial cm ports or official devices of cm for other roms not based on CM

Generally the CM devs write which location has to be patched .... otherwise simply use the search bar To apply the patch above we first have to enter the hardware/broadcom/libbt folder

STEP 2:

We then copy, the file that we downloaded earlier, to the folder that has to be patched in this case hardware/broadcom/libbt

STEP 3:

APPLYING THE PATCH

cd nameoftheromfolder/hardware/broadcom/libbt
git checkout .
patch -p1 < nameofthefile.diff or nameofthefile.patch

It should look something like this

ITS AS SIMPLE AS THIS ..... ALL THE BEST !!! HOPE THIS GUIDE HELPS ... IF YOU HAVE ANY ISSUES OR QUESTIONS PLEASE POST IT HERE ...SO I CAN HELP :-d

THANX TO CYANOGENMOD , PAWITP ,K2WL AND XENON92
[Android] RVR:
reserved
[Android] TPD-21:
Excellent, only this time I find someone who is pleased to provide this detail android science. I really appreciate this. Thank you very much :highfive:

Kindly permit marking thread, personally for reference material. :good::)
[Android] toster jp:
Woow such a great guide! Huge thanks, will do this in the evening :D
[Android] Troubadour666:
Thanks for this very useful thread.
[Android] ralpheboyo:
Excellent step by step guide!!!! Hats off and thank you for taking the time!!!
[Android] Trach:
Git Knowledge

Before i start,i would like to express my gratitude to GitSCM,Github and others who have provided a learning platform for everyone to use Git and learn Git :)

If any information was stated wrongly here,please correct me and I am open to suggestions and criticism :P

First of all,let's start off with the basics

git init

- The git init command is used to create a new git repository in your folder.It can be used to convert an existing, unversioned project to a Git repository or initialize a new empty repository.When the command git init is being executed,in the folder itself,it will create a .git subdirectory and in order to view the sub directory,you need to hold CTRL+H to view it.In the

.git

subdirectory itself contains the metadata for the repo.

git clone

- The git clone command is used to copy an existing Git repository into your folder.The cloned repository will contain all its own history and manages its own files,and its a totally isolated environment from the original repository.Important note: This is where we should always remember to keep authorship when you clone something and upload to your own github.Always remember to keep the history commits when you upload.The tutorial is here(With courtesy to [MENTION=1289361]Mazda[/MENTION])

git add

- The git add adds a change in the working directory to the staging area.Normally once it is added,it doesnt really get recorded yet until you execute the command git commit.Therefore,if you need to manage your files,execute git status to view the file changes.The various commands are

Stages the changes that was made in the file

git add <file>

Stages the changes that was made in a folder/directory

git add <directory/folder>

git commit

- The git commit command stages the snapshot to the project.This command is used after the command git add is executed and the git commit command will do the job in recording the changes you have made and sending it to the project history which will then be uploaded into Github or BitBucket.Some commands that normally developers use

The -m stands for message in full term --message

git commit -m "Hello"

The -a command is used to tell Git to stage all file changes,be it modified or deleted.Everything is added

git commit -a

The --reset-author command is used to change back to its original committer if the commits authorship have been changed

git commit --reset-author

More is coming soon! :)
[Android] methuselah:
nice

well this is the most complete guide that a first time user for ROM development should know. :good:..nice effort
[Android] k2wl:
reserved
[Android] Nelson George:
About Linux

is that possible to build rom using linux os other than ubuntu ( like arch linux, kali ) ???
[Android] TechExhibeo:
yeah :D

according to me yes you can use other linux OS but [MENTION=5216756]jackeagle[/MENTION] suggests you to use Ubuntu 13.10 as he used this version while making the guide :D

thnx alot [MENTION=5216756]jackeagle[/MENTION] for this awesome guide :D
[Android] Nikhil:
Change path of your device tree in local_manifests.xml to the one you shared above and follow instructions in post #4.

I'd use lunch instead of brunch.

Its natural. It checks output for previously compiled files and it doesnt compile them again if not modified. So basically the process continues from where you left it. (Ofcourse it checks previously compiled files once)

Post a Screenshot of the Terminal Screen in which you face error.

Or select and copy the output from terminal (error part and few lines above it), use pastebin.com and share the link.

[MENTION=5216756]jackeagle[/MENTION] I believe this belongs to FAQ. :)
[Android] david makarove:
[MENTION=5216756]jackeagle[/MENTION] [MENTION=4867515]Nikhil[/MENTION]

Thank you guys for reply:)

These tow screen shots i have them right now from latest build try

i will try send full log once i reach my computer :)
[Android] jackeagle:
Hi,

Error is in Ril that qcomril :D If u have a slim tree u can replace the qcomril content with that but sadly i guess for ur device its not there :(
[Android] Nikhil:
Are you using this device tree?

If not which then which one? Link please.
[Android] david makarove:
[MENTION=5216756]jackeagle[/MENTION] [MENTION=4867515]Nikhil[/MENTION]

okay here is my local_manifest

<manifest>

<remote name="github" fetch="https://github.com/"/>

<project path="device/sony/taoshan" name="CyanogenMod/android_device_sony_taoshan" remote="github" revision="cm-11.0"/>

<project path="kernel/sony/msm8930" name="varunchitre15/android_kernel_sony_msm8930" remote="github" revision="cm-11.0"/>

<project path="device/sony/common" name="CyanogenMod/android_device_sony_common" remote="github" revision="cm-11.0"/>

<project path="hardware/sony/DASH" name="CyanogenMod/android_hardware_sony_DASH" remote="github" revision="cm-11.0"/>

<project path="vendor/sony" name="DeviousFusion/proprietary_vendor_sony" remote="github" revision="cm-11.0"/>

<project path="device/sony/qcom-common" name="CyanogenMod/android_device_sony_qcom-common" remote="github" revision="cm-11.0"/>

</manifest>

but i when i run repo sync i get this (just wanna sync before start build and send log)

Fetching projects: 100% (380/380), done.
error: Cannot remove project "device/sony/taoshan": uncommitted changes are present
commit changes, then run sync again

waiting for help

thanks guys and sorry for a lot questions :)
[Android] Kishan14:
The answer is in your question.. U must. Have done some changes to work tree... Simple solution is to delete the working folder where u have made the changes... Then try
[Android] david makarove:
you mean i must delete manually

device/sony/taoshan ?

But i must to remodify the tree (changes will gone) ?
[Android] jackeagle:
Hi,

No problem any doubts always free to post here :) Regarding ur Problem has [MENTION=1078760]kishan[/MENTION] said delete the working tree before that save the files u modified if you know which are they for future references :)
[Android] david makarove:
thanks i got the problem

now i will sync and build then send build log :)
[Android] VnnAmed:
Hi guys I have managed to compile and people are running my build :) I still have one problem though. When I run time brunch saga -jX no matter what I put instead of X the compiling process would still use all 8 threads (I have an core i7 4 cores split into 8 logeical threads). I would love for the compiling process to use like half of my firepower. How do I do that?
[Android] Kishan14:
Try using cm tree.. Cz yea [MENTION=5216756]jackeagle[/MENTION] is ryt.. Even according to me Its RIL prob..
[Android] david makarove:
Did you saw my local_manifest that i posted in previous page ?

i am already use it

But i said about slimkat that it's dev in his thread mentione cm tree that already i use it

Thanks for reply
[Android] djmigues:
lunch saga

make bacon -j4

Brunch uses all cores and does not react to a -j flag.
[Android] VnnAmed:
Lunch says :saga invalid combo
[Android] djmigues:
Just type lunch and then locate saga and enter that number.
[Android] VnnAmed:
How do I make my next build after I have allready made one? Do I clear out folder?
[Android] Hashbang173:
I would do make clobber then sync then build
[Android] david makarove:
another try but this time with these

but same :(

but this time take around 55 minutes

still waiting for :'(
[Android] david makarove:
i fixed everything

the problem was in libril

Now i am sending this from my new ROM :D
[Android] EdwinMoq:
That's weird... It seems like some project in the manifest is not longer in the CM's repo. Which version are you trying to download?

If you are interested, here you can find highly-compressed version of the sources which can make things easier for people with low bandwidth. Just download the repo folder of the ROM you want to build (The size is about 15gb, I recommend to use a download manager.) and unpack it using tar. For example if you downloaded CM13 sources extract it by running tar -xvf cm13.0.repo.tar.xz And then change direction to the cm folder and do repo sync -j1 -force--sync.

I have a 1mbps internet and I managed to download the sources using this method.
[Android] hdorius:
I'm trying to build AICP MM from cm13 tree for Desire HD,just want to try it maybe some error in my local_manifests?
[Android] EdwinMoq:
Did you customize the local manifest yourself? Try deleting the project which are giving the error from the local manifest. Whomever edited the manifest added a project that's no longer available or was moved somewhere else.
[Android] transi1:
compiled CM13 for OMAP4 Kindel fire error on boot, proc/kmesg after.

in init.recovery.bowser.rc insert line setenforce permissive

in BoardConfig.mk BOARD_KERNEL_CMDLINE := mem=1G androidboot.hardware=bowser console=ttyO2,115200n8 androidboot.console=ttyO2 androidboot.selinux=permissive

any suppose?

[ 5.517028] init: init started!

[ 5.521544] SELinux: policydb version 30 does not match my version range 15-26

[ 5.530120] init: SELinux: Could not load policy: Invalid argument

[ 5.537078] init: failed to load policy: Invalid argument

[ 5.542937] init: Security failure; rebooting into recovery mode...

[ 5.549773] Disabling non-boot CPUs ...

[ 5.558166] sr_class1p5_calib_work: mpu: Calibration complete: Voltage Nominal=1380000Calib=1354660 margin=0

[ 5.569121] CPU1: shutdown

[ 5.572875] max44007_shutdown

[ 5.699828] smb347 3-005f: Shutting down

[ 6.066070] thermal_lookup_temp: getting temp is not supported for domain pcb

[ 6.074553] thermal_lookup_temp: getting temp is not supported for domain pcb

[ 6.082702] thermal_lookup_temp: getting temp is not supported for domain pcb

[ 6.092071] bu52061: shutdown

[ 6.095427] Disabling non-boot CPUs ...

[ 6.099700] Restarting system with command 'recovery'.

[ 6.105315]

[ 6.106963] Restarting Linux version 3.0.72+ (root@transi-VirtualBox) (gcc version 4.8.5 (UBERTC-4.8.5) ) #1$

[ 6.106994]

No errors detected
[Android] hdorius:
nope,i get it from dev's github that made cm13 for DHD,maybe i can try it tomorrow..its too late now in my country,thx
[Android] Simba83:
Im not able to build even though i fix the vendor thing: http://pastebin.com/rBbiQX8Y
[Android] EdwinMoq:
make: *** No rule to make target `vendor/lge/g2-common/proprietary/bin/mpdecision', needed by `/home/simon/RR/out/target/product/d802/system/bin/mpdecision'. Stop.

There's the problem. You're missing vendor files. Where did you get the vendor blobs? You can find the vendor files for the LG G2 here.
[Android] EdwinMoq:
You need to update SElinux in the kernel to be compatible with Marshmallow.

To apply the patches copy the diff files to the kernel sources folder and then apply the patches one-by-one. Like this:

patch -p1 < 27.diff

patch -p1 < 28.diff

Etc.
[Android] Simba83:
Thanks now everything works, I did use the ./extract-files.sh and extracted the files from the phone but something must have been wrong. Thanks to you I'm now running my first own compiled ROM.
[Android] transi1:
big thnx