[Android Software/Hacking General [Developers Only]] gokussjx:
NOTE:

The method explained here is to be followed for compiling ParanoidAndroid v3.+

The process is WIP.

Feel free to try & compile, post your results/errors here. Community effort would make this a lot faster. :)

WELCOME TO PARANOIDANDROID

Source Compilation Guide v3.+

​

Hello, & welcome to a complete reference guide on compiling ParanoidAndroid from source!

I've been getting a lot of mails & PMs, asking for help on PA compilation. I could only help 3 of them, after which, it wasn't feasible for me.

So, here we are, as promised! :cowboy:

This guide will walk you through each & every step involved in compiling the ROM, right after the stage of installing Ubuntu.

This is to help you all explore your own development domains. :)

Remember, I'm NOT responsible if something, or anything goes wrong at your end, on any device or system.

I, & others, will try & help you out whenever possible. If there's some delay, don't whine or complain, just have patience & you'll be helped.

I can't practically reach out to everybody, but I'll try my best.

So, with that,

Good Luck :good:

------------------Pre-requisites------------------​

Make sure you have:

Ubuntu 12.04 (Precise Pangolin) 64-bit

Decent Computer, with at least 4GB RAM

Decent Internet (Trust me... you DON'T want to do this on a 512 kbits connection...)

Functional Device Tree, Hardware tree, Kernel source tree for your device

Device with support for latest CM10.2/AOSP 4.3 Jellybean

------------------Steps Involved------------------​

Step 1: Download the sources

Step 2: Add device support to PA, & Builiding ROM

Step 3: The After-life: Git, Gerrit, Patch Submissions

------------------Lets Start :cowboy: ------------------​

STEP 1: Downloading the Sources​

For the curious kind, here's some theoretical information:

Before compiling any ROM, we need some basic 'stuffs', or tools if you may.

In short, here's what we need:

1) Compile Dependencies (libs)

2) Python 2.7.3

3) Java JDK 6.xx

4) Android SDK

5) USB Configs

6) Git, Repo

7) Project Sources

8) CM10.2/JellyBean Device Tree

9) Device Kernel Tree

10) Device Hardware sources

11) Device Vendor Proprietaries
​

# Install OpenSSL, for Python:

$ sudo apt-get install libssl1.0.0=1.0.1-4ubuntu5.3
$ sudo apt-get install libssl-dev

# Install Dependencies:

There are some dependencies that might not be useful. But just in case, I'm gonna give you all dependencies that any Android compilation would need. Its better than facing errors while compiling.

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev \
ia32-libs x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 \
lib32z-dev 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.6-dev

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

# Configure USB:

1) Open/Create file 51-android.rules:

$ gksudo gedit /etc/udev/rules.d/51-android.rules

-> Add these lines:

#Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091E", MODE="0666"

#Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666"

#HTC
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666"

#Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666"

#K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666"

#KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666"

#Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666"

#Lenevo
SUBSYSTEM=="usb", ATTR{idVendor}=="17EF", MODE="0666"

#LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666"

#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666"

#NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666"

#Nook
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666"

#Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666"

#OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666"

#Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10A9", MODE="0666"

#Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666"

#PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666"

#Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666"

#SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666"

#Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"

#Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666"

#Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666"

#Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666"

#ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19D2", MODE="0666"

2) Save & Close

3) Set proper permisisons: (Provide read permission to all users, in addition to whatever other permissions are pre-set)

$ sudo chmod a+r /etc/udev/rules.d/51-android.rules

# JAVA JDK Installation:

1) Download & keep aside the latest Oracle Java 6 JDK. (I dislike OpenJDK. Feel free to use it if you prefer that ;) )

Remember: WE NEED JAVA 6, not any other version (5 or 7 etc). Or this will not work for you.

http://www.oracle.com/technetwork/java/javase/downloads/jdk6-downloads-1637591.html

2) Remove other JAVA Packages:

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

3) Install JAVA JDK:

$ sudo mkdir -p /opt/java/64/
$ sudo cp jdk-6u[COLOR="Red"]##[/COLOR]-linux-x64.bin /opt/java/64
$ sudo su -
$ cd /opt/java/64
$ chmod +x jdk-6u[COLOR="red"]##[/COLOR]-linux-x64.bin
$ ./jdk-6u[COLOR="red"]##[/COLOR]-linux-x64.bin
$ exit

REPLACE THE HASHes (#) WITH YOUR VERSION NUMBER.

-> Save & Exit

4) Add JDK PATH to .bashrc:

$ gksudo gedit ~/.bashrc

-> Add these lines:

# Java PATHs
export JAVA_HOME=/opt/java/64/jdk1.6.0_[COLOR="red"]##[/COLOR]
export PATH=$PATH:$JAVA_HOME/bin

REPLACE THE HASHes (#) WITH YOUR VERSION NUMBER.

# Python Installation:

For Python installation, I give you two choices. Pick whichever you like. But pick ANY ONE.

Option 1:

Direct package installation: (Easy way)

$ sudo apt-get install python

-----OR------

Option 2:

Self compile Python from source: (Advanced way. Not recommended if you have no experience with software compilation)

1) Download Python 2.7.3:

http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz

-> For 2.7 you need to explicitly enable SSL after running the ./configure script and before running make:

2) Configure Python:

$ ./configure

3) Navigate to & open Modules/Setup.

There are lines like this:

#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto

4) Uncomment these lines and change the SSL variable to /usr:

SSL=/usr
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

5) Install Python:

$ make
$ sudo make install

6) Add Python PATH to .bashrc:

$ gksudo gedit .bashrc

-> Add these lines:

# Python
export PATH=/usr/bin:$PATH

-> Save & Exit

# Android SDK:

1) Download the SDK here:

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

2) Extract the SDK and place it in your home directory.

3) Add AndroidSDK PATH to .bashrc:

$ gksudo gedit .bashrc

-> Add the following lines:

# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
export PATH=${PATH}:~/bin

->Save & Exit

4) Add PATH to .profile:

$ gksudo gedit .profile

-> Add these lines:

PATH="$HOME/android-sdk/tools:$HOME/android-sdk/platform-tools:$PATH"

-> Save & Exit

*To use the ADB Update software (or to verify a working adb path), use the following command:

$ android

# Install the Repo:

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

# Initialize the ParanoidAndroid Repo:

$ mkdir android
$ cd android
$ mkdir system
$ cd system
$ repo init -u git://github.com/ParanoidAndroid/manifest.git -b [B]jb43-legacy[/B]

VERY IMPORTANT: Now, before the final stage sync, make sure there's no code referring to 'ParanoidPreferences' in manifest.

To check that

1) Open your File Browser,

2) Press Ctrl+H (to show hidden files/directories)

3) Navigate to android/system/.repo/manifest.xml

(Right Click & open the XML file in text editor)

*REMOVE ANY 'PARANOIDPREFERENCES' CODE FROM MANIFEST*

*REMOVE GROUPER DEVICE TREE FROM MANIFEST* (This'll be useless, unless you're compiling for Grouper: Nexus 7)

-> Now, Lets add the device specific trees:

Add your own device tree, kernel tree, hardware source tree, & vendor proprietaries tree in the local manifest.

For this, create a new file .repo/local_manifest.xml, & use something in similar terms:

For example, I'm using all corresponding trees for Samsung Galaxy S3 i9300 - International

Following is just an example, not what you should copy/paste. SEARCH & USE YOUR OWN DEVICE SPECIFIC TREES.

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="ParanoidAndroid/android_device_samsung_i9300" path="device/samsung/i9300" remote="github" revision="cm-10.2" />
<project name="CyanogenMod/android_kernel_samsung_smdk4412" path="kernel/samsung/smdk4412" remote="github" revision="cm-10.2" />
<project name="ParanoidAndroid/android_device_samsung_smdk4412-common" path="device/samsung/smdk4412-common" remote="github" revision="cm-10.2" />
<project name="TheMuppets/proprietary_vendor_samsung" path="vendor/samsung" remote="github" revision="cm-10.2" />
<project name="CyanogenMod/android_packages_apps_SamsungServiceMode" path="packages/apps/SamsungServiceMode" remote="github" revision="cm-10.2" />
<project name="CyanogenMod/android_hardware_samsung" path="hardware/samsung" remote="github" revision="cm-10.2" />
</manifest>

CAUTION:

Your device tree, kernel source, vendor props etc WILL be different. Search & find out where your device specific sources are located.

# Sync the Repo

$ repo sync [COLOR="Red"]<-parameters->[/COLOR]

Now, here's a reference to the repo sync parameters:

“make” command has ‘-j’ option to run multi jobs parallely. “repo sync” has similar option, too.

Let’s examine command line help:

$ [B]repo sync[/B] [COLOR="Red"]-h[/COLOR]
Usage: repo sync [...]

Options:
[COLOR="red"]-h[/COLOR], [COLOR="red"]--help[/COLOR] show this help message and exit
[COLOR="red"]-f[/COLOR], [COLOR="red"]--force-broken[/COLOR] continue sync even if a project fails to sync
[COLOR="red"]-l[/COLOR], [COLOR="red"]--local-only[/COLOR] only update working tree, don't fetch
[COLOR="red"]-n[/COLOR], [COLOR="red"]--network-only[/COLOR] fetch only, don't update working tree
[COLOR="red"]-d[/COLOR], [COLOR="red"]--detach[/COLOR] detach projects back to manifest revision
[COLOR="red"]-q[/COLOR], [COLOR="red"]--quiet[/COLOR] be more quiet
[COLOR="red"]-j[/COLOR][COLOR="SeaGreen"]JOBS[/COLOR], [COLOR="red"]--jobs[/COLOR]=[COLOR="SeaGreen"]JOBS[/COLOR] number of projects to fetch simultaneously
[COLOR="red"]-s[/COLOR], [COLOR="red"]--smart-sync[/COLOR] smart sync using manifest from a known good build

repo Version options:
[COLOR="red"]--no-repo-verify[/COLOR] do not verify repo source code

So, for instance, if you want to run 8 fetching jobs parallelly,

$ repo sync [COLOR="Red"]-j[/COLOR][COLOR="SeaGreen"]8[/COLOR]

I personally use -j4, due to my awful internet. You may use any no. of jobs value, like -j16.

This can reduce the download time. However, this'll suck lots of the bandwidth of the network. Just so you know ;)

Now that you have the sources, its time to deal with the precompilation & compilation steps :cowboy:

Move on to Post 2.

---------------------------------------------------------------------------------

Credits:

- molesarecoming

- D4rKn3sSyS

- dastin1015

- Perka

- pmos69

- ProTekk (Rootzwiki)