Remove All Ads from XDA

[HOW-TO] Dev basic´s: Source, Compiling, Github & co ~ Day 4

n/a posts
Thanks Meter: 0
By fuss132, Guest on 17th July 2012, 07:37 PM
Post Reply Email Thread
Welcome to fuss132 dev basic´s

So you want to become a developer for android? You dont know where to start? Well, I will try to give you some point you can start with.
"There are many tutorials on compiling source code?", you may ask "So no need of this?". No, youre not right. Of course there are many how tos that explain you how to compile something... but to do the magic there is more needed than just "Execude this commands and ready". You need to know the things behind, you need to get the flair of android.

What I want:

First of all, I know that there are many people that see how devs are failing; or some that need help and those people cant help them. They have the time to learn something, but they dont know how. You can expect a point to start with, some welcome drink of android development. Expect the falir of android! Join the android open source project! I posted this in the I9100G section, because I use my kernel (called horsepower) as an example, but it can be used for every device! And please if I helped you thank me in whatever post I helped you I´m doing this in my spare free time to help you!

What I dont want:

I cant give you everything! You will need some time, it took me one and a half years to get to know a big part of how android works and stuff. You will not be a "full" developer after this! Furthermore, I dont teach you for 10 variants of my kernel coming up at the forum or of cm roms what ever! Android is an opensource project. This means creating something new - but together. If you did something you think its worth to publish make a git push request and your work will be included to my kernel f.e. Every dev that notice your work will let you post in his thread and your work will be thanked!

Also required for this howto:
  • A computer running ubuntu 12
  • Some basic ubuntu terminal knowledge
  • Time and more time

Also a good internet connection could be usefull

How it will work:
So you think you can manage this? Good luck, I will help you whereever I can. But please understand, that my work on kernels and roms will come first I will try to post every day a new tutorial. We will start with setting up your computer and will end up in some weeks with compiling your own aosp rom. Ready? So lets go to the second post here and start with Day 1: Introduction

PS: Well we only have one forum so, besides this fact that this is about learning developing, I posted it here...
The Following 65 Users Say Thank You to fuss132 For This Useful Post: [ View ] Gift fuss132 Ad-Free
17th July 2012, 07:37 PM |#2  
Thanks Meter: 0
Day one: Introduction and downloading source code

This is all for jellybean!
So no longer talking about developement, let´s do some of itselfe.
We first need the source code. For completeness we will download both - kernel source and main rom source. If you dont know what kernel is for please stop reading here... you will fail 99,9999%. (Maybe you just forgot which files this is for: Kernel is the boot.img in your´s and the rest located in /system is the compiled main rom.)

1. Creating your working directory and stuff

You should know the commands, just use the same folder names and structure for a better chance that I can help you if something goes wrong.


mkdir cyanogenmod
cd cyanogenmod

2. Downloading the source and required software

At this part we use a very useful build script made by teamhacksung, thanks to them!
Staying at your /cyanogenmod folder do the following (What this git command mean ~ well dont think about it we will learn it afterwards):


git clone git:// -b cm-10.1 buildscripts
ln -s buildscripts/samsung/
./ prepare

This script will now do some very useful things for you Select the specifics of your system and wait for finishing till the point "Download sources?" Tipe a "y" and select "cm-10.1". (When it asks for your folder you want the source in only tipe "sources" and hit enter). This will download the main uncompiled canogenmod sources for you (including some kernel and device specific stuff). It will take looong Depeding on your net connection. Some hours usually

3. Downlading kernel sources and recovery stuff

Everything went well? So this means we need to go further. In /cyanogenmod/sources should now be some folders and files... And now we should download a kernel source for our device (choose one for your device, I will use I9100G ones).
Navigate to your source and execute


cd cyanogenmod
cd sources
mkdir kernel/samsung/
cd kernel/samsung/
git clone -b greenblob-4.2.2 t1

Hah, you now have latest greenblobkernel source on your computer.
But to finally build the kernel and rom we will also need some device specific files for our I9100G. For other devices you will find these files when you search on gitbub. Or google device xy ics device tree.


cd cyanogenmod
cd sources
git clone git:// -b cm-10.1 device/samsung/i9100g

As it finished you have all the sources you need

Thats enough for day one, I think. See you soon
The Following 24 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
17th July 2012, 07:38 PM |#3  
Thanks Meter: 0
Day 2: Github basics part 1

So we successfully downloaded all sources. Brilliant, now let´s go on. In future time you may work on kernels of even the main rom, and of course you should upload the changes you made to contribute to the community. You will need github for this. For some basic info go here I will only focus on how to use it.

The script from above post should already installed git, if not do the following:


sudo apt-get install git

And you should also register an account for free at -> here

As you did this we will also need to set up your github account on your computer, so use the following commands and replace it with the email adress and username you chose before:


First we should be in our kernel example local repository so use cd /cyanogenmod/sources/kernel/samsung/t1 to switch to it
git config --global "Your Name Here"
git config --global ""

If you now upload some changes you have to enter your password every time. To make the things easier we will use an ssh key and will add it to our github account. Its not important to know what all these commands are doing just do them


ssh-keygen -t rsa -C ""
//Now you need to enter a passphrase.
sudo apt-get install xclip
xclip -sel clip < ~/.ssh/ <- this is the path to your stored key

Now go to, login and click "add ssh key". Choose a name (doesnt matter which one) and paste your key from your clipboard into the field below. Thats it github is now set up

1. Some basics commmands

There are some basic commands you should know. Firstly, some explanations for you. The source you downloaded is stored on
With git clone you can download new files and sources from existing repositorys.

When you change some files in your local repository (all files from one source path f.e. cd /cyanogenmod/sources/kernel/samsung/t1 and then execute and then) use git status to display the changes you made.

You made some changes? Then pack these changes into a commit by typing git add -A and also add a commit message that will appear later like git commit -m "Camera freeze fix" and finally upload it: git push. We will make some practical examples tomorrow, so dont worry about this now. Just keep that in mind.

Thanks for reading and see you tomorrow!
As usuall, if you like this thread and stuff please submit it as news tip!
The Following 18 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
17th July 2012, 07:38 PM |#4  
Thanks Meter: 0
Day 3: Github basics part 2 and preparing for compiling

Welcome to Day 3: Github basics part 2 and preparing for compiling! Lets beginn our "session" with a short test. Remember which command you have to use for cloing a repository (downloading the files to your computer)? Well we need this one here.

1. Again Github basics

Imagine the following situation; You want to help another person to fix a bug. You should create your own repository first to dont mix files up. In short we copy all files from a repository to our own new one. We have a point to start then and will use his code, but his code wont change when we change ours.

Go to and login

I create a short repository for you all, nothing special but you can practise with it.
Open the following page (its the repositiory shown in your webbrowser: Click on fork at the right:

If github is asking you to which user it should fork the files click the only availabe button ^^

You have now your own repository with the same files. We will download the files now. Open your terminal and navigate to the folder (it should be an empty one). So you have to do the following:


cd whereeveryyouwantit
git clone<b>yourusernamehere</...repository.git

Now we "fix the bug" and do some changes to your local files.


cd tutorialmembers
sudo gedit memberlist
// add your name to the list, save and exit //
cd ..

So we made the changes, now we will upload them, you should know the commands already. If you have any questions please post in this thread


git status
git add -A
git commit -m "add my name to the list"
git push

Brilliant, if you know visit you will see that your changes have been uploaded. So you fixed my problem, you should now share the solution with me.

Open your repository in a webbrowser and click on Pull Requests on the right side. Now select on the right side as head repo mine fuss132 one and as base repo in the left the default, your one. Describe what you did in the filed below and finally click on "Send pull request.

Thats it you now shared it with me and I will include your changes to my repo

2. Back to the roots: Prepare for compiling

Now cd to the folders you downloaded all the sources in. You should see folders like bionic, fendor, main... I will call this main source directory now
If you would compile the sources now you would stuck after some seconds Android needs a special java version for building. And this one cant be downloaded anymore. Well, bad situation... We will give up here we will never compile android :'(

Ok, **** you java we will rule you

There is an error only because the build system does not recognize the java version when it is an openSDK

$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu2)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

To work around it, you can just comment out the following lines in build/core/


cd build/core/

instead of
ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
java_version :=

there should be

# ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
# java_version :=
# endif

Java is now no longer checking its version and everything is working. Stupid solution, but working

The second part is that the linker would complain that it cannot find -lGL .

The workaround for it would be:

just execute this line:


sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/ /usr/lib/

The last thing what we need is again the buildscript file, just do the following (you dont have to remember this):


// be in the main directory of your sources //
copy all lines from and paste them into your file
save and close
in terminal: chmod 777

Thats it for today, thanks for reading! Please press thanks if you like it and maybe click on "newsworthy thread". Questions, as usuall in this thread please
The Following 17 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
17th July 2012, 07:39 PM |#5  
Thanks Meter: 0
Day 4: Compiling your first things and looking into the source code

It´s been a long time since we met the last time, I hope you didnt forgot everything. If you did - you know - just go to through the first posts and learn again. Sorry that it took so long for you to wait, but I´m writing this in my spare free time and I´m involved into many many projects at this time that are more important that this one. But I didnt forget you! So lets go in again and start coding!

1. Going through the source code

I know, I turned things around in the title of this thread, but compiling will take a very long time so lets go through the source code first.
Open a file explorer and navigate to your root forlders. You will see there many folders. As you all know, Cyanogenmod is a Custom Rom and adds much features to your devices, thats why they are using custom product configs. One for each phone and one for all phones.

Let´s go into the folder vendor/cm. You will see a file called "" in which all available devices are written in.

Ok, you will wonder why theres only something like this in your folder if you downloaded the sourcecode for Cyanogenmod 10:


for combo in $(cat vendor/cm/jenkins-build-targets)
add_lunch_combo $combo

Because since cm10 they´re doing things a bit different. In the next few days we will download the aokp source code and start porting aokp to a new device, because aokp is using the old building system like in cm9 and previous version - and I want that you know all of them. So back to our cm10 thing: All product specific files are now directly in the source code of the device, the device tree. Its the one we downloaded and stored in /device/samsung/i9100g.

But to build a fully working Cyanogenmod Rom we need more that only te device tree, we need some proprietary files from your device. In short, they are files that are very device specific like (a camera module only for our device) that is pre generated and could not be build by our system. (Thats also the reason why developers cant edit it. We are not able to edit it, too). To pull all those files from your device, please connect it and be sure that you are already running a cyanogenmod 10 rom, otherwise some files might be different and not be copyed - your rom will not be successfully build.

Open our terminal and execute:

sudo bash
cd cyanogenmod/sources/device/samsung/i9100g
chmod 777
Using adb all the files are now being pulled from your device and stored in the right directory of your system. If you successfully did this (and I didnt forget something) we should be now able to compile our own cyanogenmod rom.

2. Compiling your rom

So let´s go! (We will update the sourcecode before again, maybe some cool things changed). We will not use the build script for this, we´re doing things "oldschool". If you want to make things as easy as possible do ./ i9100g and everything will be done for you.


sudo bash
cd cyanogenmod/sources
repo sync

/* start building*/
. build/

/* pick the device you are building for */
make bacon or make fullota or make -jx (where x is the number of your cpu cores)

And now we have to wait some hours depending on your computer. I´ll catch you guys in the next tutorial!

Please press thanks and submit this thread as newsworthy one! Thank you and have a good time
The Following 18 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
17th July 2012, 07:39 PM |#6  
Thanks Meter: 0
First page of the thread!
The Following 6 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
17th July 2012, 07:40 PM |#7  
Thanks Meter: 0
This post also...
The Following 6 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
17th July 2012, 07:40 PM |#8  
Thanks Meter: 0
3 left if my math education not failed
The Following 6 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
17th July 2012, 07:41 PM |#9  
Thanks Meter: 0
Oh no, it was just one... hmm thats why I want to became a computer scientist not a mathematician ^^
The Following 5 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
17th July 2012, 08:42 PM |#10  
rcade2005's Avatar
Senior Member
Flag Chennai
Thanks Meter: 230
Angry newsworthy thread

Submitted as newsworthy thread . Guys pls do the same if its useful to u guys . First to comment n ur thread
The Following 2 Users Say Thank You to rcade2005 For This Useful Post: [ View ] Gift rcade2005 Ad-Free
17th July 2012, 08:51 PM |#11  
Senior Member
Flag sabah
Thanks Meter: 16
+1 will wait time after time..
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes