Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,807,597 Members 51,278 Now Online
XDA Developers Android and Mobile Development Forum

[TUTORIAL ] Beginning development-the easy way

Tip us?
 
nerotNS
Old
(Last edited by nerotNS; 22nd May 2013 at 02:36 PM.) Reason: Partial rewrite and added files for Ubuntu 12.04
#1  
nerotNS's Avatar
Recognized Contributor - OP
Thanks Meter 394
Posts: 1,011
Join Date: Nov 2011
Location: 45.2500 N, 19.8500 E (Novi Sad)

 
DONATE TO ME
Default [TUTORIAL ] Beginning development-the easy way

Ok so this is a guide that me and my friend made for compiling ROMs for our LG-P350 Now, this is pretty much universal and can be used for general development

This is the stuff you will need :

Ubuntu-can be found on the Ubuntu website http://www.ubuntu.com/start-download...64&release=lts (this is a direct link to the Ubuntu 12.04 64-bit version)
Python (included)
GNU Make
Java Development Kit (JDK) 6
Git

Before you can do anything you need to install Ubuntu. You can go with newer versions but i still think that 10.10 is best and this guide is adapted to it. You can install it like dual boot or use Wubi (Windows Ubuntu Installer). However if you choose Wubi there is a good chance that you won't have enough storage, so that's not recommended.Those who want to dual-boot check out this post http://forum.xda-developers.com/show...8&postcount=26

NOTE: You can do this in a virtual machine (for example VM Ware and Virtual box) but it will be a lot slower unless you have a VERY strong CPU and a LOT of RAM.

Generally Python is not needed since it's already in Ubuntu. However if you want to install it separately here's how:

First of all open the terminal. Now copy/paste these codes (one by one) and execute them:

Code:
sudo apt-get install build-essential gcc

cd Downloads

wget http://www.python.org/ftp/python/2.5.6/Python-2.5.6.tgz

tar -xvzf Python-2.5.6.tgz

cd Python-2.5.6

./configure --prefix=/usr/local/python2.5

make

make test

sudo make install (NOTE: You will be asked for your password, enter it and press enter) 

sudo ln -s /usr/local/python2.5/bin/python /usr/bin/python2.5
Now you need Sun JDK 6. Same procedure as with Python:

Code:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

sudo apt-get update

sudo apt-get install sun-java6-jdk
For those who get package error try these:

Code:
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jdk
sudo update-java-alternatives -s java6-jdk
Now that JDK is installed it's time for GNU Make:

First of all download GNU Make from link given. Download version 3.82
Now extract the downloaded file to your Home directory.
Go to Home directory and change the name of GNU Make To make
Now open the Terminal and type the following codes

Link: http://ftp.gnu.org/gnu/make/

Code:
cd make

./configure

sudo make install
Now make is installed.

Next, we are going to install the dependencies:

FOR UBUNTU 10.10

Codes to type in terminal :

Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \ x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \ libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \ libxml2-utils xsltproc

export USE_CCACHE=1
If that method didn't work then try this:
You use the same commands BUT the first one is:
sudo apt-get install git-core gnupg flex bison gperf build-essential

Now it should download some stuff. When its done you need to do the same for the rest in the right order.
NOTE: Since I don't remember the right order i will just put the commands how they should be written if you get error read what's missing and put that in first.

Here are the rest of the lines:

Code:
sudo apt-get install zip curl
sudo apt-get install zlib1g-dev
sudo apt-get install libc6-dev
sudo apt-get install lib32ncurses5-dev
sudo apt-get install ia32-libs
sudo apt-get install x11proto-core-dev
sudo apt-get install libx11-dev
sudo apt-get install lib32readline5-dev
sudo apt-get install lib32z-dev
sudo apt-get install libgl1-mesa-dev g++-multilib
sudo apt-get install mingw32
sudo apt-get install tofrodos python-markdown
sudo apt-get install libxml2-utils
sudo apt-get install xsltproc

FOR UBUNTU 12.04

Code:
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

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

Now for the Android SDK, ADB and ADB path:

1. SDK (Software-Development-Kit) :

Go to this link and download the Android SDK for Linux:

http://developer.android.com/sdk/index.html


After downloading it, extract it to the Home folder. You can probably extract where you want and change all the steps below to to fit your set up, but I like putting it in Home folder.
When you have extracted it in the Home folder change the name of the folder of android-sdk-linux to sdk.

Then open the Terminal and run these codes:

Code:
cd ~/sdk/tools/
./android sdk
When you run this, a window will pop up. For this you only need "Android SDK Tools" and "Android SDK Platform-tools". Just check these two and install them.

2. ADB (Android-Debug-Bridge):

Run this command to see if your ADB works. You have to have your android device connected in debugging mode.

Run these codes in the Terminal :

Code:
cd ~/sdk/platform-tools ./adb devices
When you entered the codes above, you should see something similar to this:
List of devices attached 0123456789ABCDEF device


NOTE: If you see output like given bellow we need to give the device permissions. Don't worry I had this too when I set my computer up for the first time.

List of devices attached ???????????? no permissions

Here is how we fix it:


Open the Terminal and type this:

Code:
gksudo gedit /etc/udev/rules.d/51-android.rules
After you've entered it, a window will pop up that will be blank. Now add the following commands and save it.

Code:
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
Now save this File And follow the given codes

After you've entered those codes type these codes in too.

Code:
sudo service udev restart 
sudo adb kill-server 
sudo adb start-server
After you've entered those codes, restart Ubuntu.

Now to see if the problem is solved type these codes in:

Code:
cd ~/sdk/platform-tools ./adb devices
If everything is ok a output similar to this will be shown:
List of devices attached 0123456789ABCDEF device

Now to add the ADB path to system, so you don't have to cd to the SDK folder every time you want to use ADB:

So, first open up .bashrc with these codes:

Code:
sudo gedit ~/.bashrc
A window will pop up and there will be some text there. Scroll down to the bottom and add these lines:

Code:
export PATH=${PATH}:~/sdk/tools
export PATH=${PATH}:~/sdk/platform-tools
After you've done that, save it and reboot Ubuntu.

If everything is ok, you will get some output when you type the following codes in the terminal.

Code:
./adb devices
OR

Code:
adb shell
If you see:

[CODE]adb not found[CODE]

Then it means you've done something wrong and ADB is not configured.

Next is GIT:

Open the browser and download git from given link
http://git-core.googlecode.com/files/git-1.7.9.6.tar.gz


Extract GIT-1.7.9.6.tar.gz to your home directory
Rename the folder you extracted to from GIT-1.7.9.6.tar.gz to git

After you've done that, enter the following codes in the Terminal

Code:
sudo aptitude build-dep git-core
sudo apt-get install zlib1g-dev
cd git
./configure
make
sudo make install
NOTE: If it doesn't work then install from this link:

http://kibyegon.wordpress.com/2010/0...u-lucid-10-04/

If the commands from above are not working then try this:

Code:
sudo apt-get install git-core
sudo apt-get install git
git
If it worked it should show this:

Code:
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
[--help] COMMAND [ARGS]
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG

See 'git help COMMAND' for more information on a specific command.



Now we will download the Repo and get the source code:

Codes to type in the Terminal :


Code:
mkdir ~/bin

PATH=~/bin:$PATH

sudo apt-get install curl

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

chmod a+x ~/bin/repo

mkdir source

cd source
Ok so up to this part its mostly universal. However after this you need to sync up sources for your device. This will probably take a long time depending on your internet speed since the source is very big (also it will take up a lot of drive space: 14-30GB). After that you should build.

How to build

First you will need to get proprietary drivers from your device.
Connect your device via USB and enter the following commands (from the root of your source repository):


Code:
cd device/xxx/xxx where x is the path to your device
./extract-files.sh
cd ../../..
NOTE: Some developers can include these files in the source itself or can make them available for download from their Github page. Check that out with your developer for more info.

And start the build:

Code:
. build/envsetup.sh xxx
NOTE:Here x also varies since its unique for every device model

Now Android is building. You may need to wait a long time (depending on your hardware-mainly CPU and RAM for example I have a quad core 2.92Ghz CPU and 6GB of HyperX DDR3 ram and it took me about 10min for CM7 and about 20-30 min for CM9).Once it's done you should get this message:

Code:
Package complete:xxx.zip
That is your flashable .zip file you install from recovery.

Credits: Many thanks go to Keyur Maru who helped me learn how to develop and for making the base of this guide.

Reference: http://source.android.com/source/downloading.html
My devices:




The Following 61 Users Say Thank You to nerotNS For This Useful Post: [ Click to Expand ]
 
sangosnip69
Old
#2  
sangosnip69's Avatar
Senior Member
Thanks Meter 375
Posts: 570
Join Date: Dec 2010
Location: Lyon

 
DONATE TO ME
Very good tutorial for beginner
Developer of SaNgO Vizion



If I've helped you, please press the thanks button!
This encourage me to continue my work!
The Following User Says Thank You to sangosnip69 For This Useful Post: [ Click to Expand ]
 
nerotNS
Old
#3  
nerotNS's Avatar
Recognized Contributor - OP
Thanks Meter 394
Posts: 1,011
Join Date: Nov 2011
Location: 45.2500 N, 19.8500 E (Novi Sad)

 
DONATE TO ME
Quote:
Originally Posted by sangosnip69 View Post
Very good tutorial for beginner
Thanks we tried our best since this is supposed to boost our dev base for our LG
My devices:




The Following 2 Users Say Thank You to nerotNS For This Useful Post: [ Click to Expand ]
 
Nasty_z
Old
#4  
Nasty_z's Avatar
Senior Member
Thanks Meter 449
Posts: 1,134
Join Date: Feb 2012
Location: Manama, Bahrain
Definitely one to try at home!

Sent from my GT-I9100 using xda premium
 
pranks1989
Old
#5  
Senior Member
Thanks Meter 128
Posts: 380
Join Date: Nov 2011
Location: Pune

 
DONATE TO ME
Wow 10min is real fast!! I recently tried CM9 directly from one of the Dev's forked repo and after about 4hours of build I got some build error! I need to get a better computer soon if I plan to get my hands real dirty! And if I may I have few suggestions - please mention that it will take a while to download the full repo from google sources else beginners may end up thinking something is wrong(which I did since it took me one full day to sync everything) and that it needs atleast 20-30GB disk space too..(Coz not everyone has Ubuntu as the only OS, I have three in my lapi!!)

A very good guide on the whole for a beginner!!!
My devices:
  • Moto G
    Current: Stock
  • Motorola Defy MB525
    Current: CM7(Kank)
  • Motorola Defy+ MB526
    Current: Latest build CM10.2(Quarx)
  • Samsung Galaxy SII(I9100)
    Current: Cyanfox
  • Spice MI 280 - Backup phone. Stock GB.
  • Nexus 7 2013 (32GB WiFi)
  • Galaxy Fit (GF) - CM7.2 Stable
Beats_ALSA_eq and ACID Audio Engine V1.0 rocks my phone!!

Android Users India (Group in FB)
The Following User Says Thank You to pranks1989 For This Useful Post: [ Click to Expand ]
 
Kayant
Old
#6  
Kayant's Avatar
Recognized Contributor
Thanks Meter 3,048
Posts: 1,548
Join Date: Jul 2011
Location: London
Quote:
Originally Posted by pranks1989 View Post
Wow 10min is real fast!! I recently tried CM9 directly from one of the Dev's forked repo and after about 4hours of build I got some build error! I need to get a better computer soon if I plan to get my hands real dirty! And if I may I have few suggestions - please mention that it will take a while to download the full repo from google sources else beginners may end up thinking something is wrong(which I did since it took me one full day to sync everything) and that it needs atleast 20-30GB disk space too..(Coz not everyone has Ubuntu as the only OS, I have three in my lapi!!)

A very good guide on the whole for a beginner!!!
Very true a great in depth and very informative tutorial for noobs like i was this would have helped me a lot.... Great work

btw pranks1989 i can help you with compiling for defy.... I used to compile roms from eppy's and quarx2k github and never got a error once it else onece eppy pinted out the mistake i was doing.... just send me a pm of your errors and i will try help
 
serendipityguy
Old
#7  
serendipityguy's Avatar
Senior Member
Thanks Meter 466
Posts: 1,088
Join Date: Oct 2010
Location: Pasadena, CA
Lightbulb Great start for me!

You have been thanked!

Great start for me!

What would the procedure be if you want to create a rom that you can flash via Odin or Heimdall on a Mac client?
 
dbarrera
Old
#8  
dbarrera's Avatar
Senior Member
Thanks Meter 92
Posts: 503
Join Date: Jan 2012
Location: Guayaquil
The guide I've been looking for ever since I had my first Android device (actually, my Optimus Me is my first Android device)...
 
goan0900
Old
#9  
goan0900's Avatar
Senior Member
Thanks Meter 133
Posts: 245
Join Date: Mar 2011
Location: Kaltensundheim

 
DONATE TO ME
Thanks for this great guide. I will try it today.

I already compiled a Rom, it took me 40 min. AMD 8 Core 3,1 MHz and 16 GB DDR3

But when i try a different device i always get errors, i hope your Guide will get me in to it.
Basteldroid - eigene Android App programmieren, einfach und nachvollziehbar

if i helped you, you could hit the THANKS button or
if you can/like, help me to BUY me a Beer to get PARANOID
 
nerotNS
Old
(Last edited by nerotNS; 1st June 2012 at 08:03 AM.)
#10  
nerotNS's Avatar
Recognized Contributor - OP
Thanks Meter 394
Posts: 1,011
Join Date: Nov 2011
Location: 45.2500 N, 19.8500 E (Novi Sad)

 
DONATE TO ME
Quote:
Originally Posted by serendipityguy View Post
You have been thanked!

Great start for me!

What would the procedure be if you want to create a rom that you can flash via Odin or Heimdall on a Mac client?
I don't know but it's surely different for odin(I'm not sure that you can).And I don't know on mac either since I use ubuntu and windows. You can look up info on this on the official Android dev website.

Sent from my Optimus Me using xda premium
My devices:





The Following User Says Thank You to nerotNS For This Useful Post: [ Click to Expand ]
Tags
compile, development, easy, source
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes