[Xperia Z1 General] ekanix20:
This guide will help you you to compile your "own" Paranoid Android ROM!

V1.0 - 2014-06-09

Picture loaned from SuperHanss Paranoid Android thread.

CREDITS AND THANKS TO:

Raum1807 for his awesome cm11 guide, I used that as a template.

SuperHanss

gokussjx

Pirateghost

SferaDev

MasterAwesome

Paranoid Android TEAM

CM TEAM

Please pm me if i forgot someone or if have to take this down!

Overview

1: Preparation

2: Install the required packages to build

3. Install & setup Java

4. Initialize repo and sources

5. Building the ROM

6. Renew sources and build again

I recommend you to read the whole guide one time without doing anything. Then you can start over and mimic the steps.

1. Preparation

Things you need for building:

A computer

An internet connection

An open mind and common knowledge

Time

Patience

First of all, you need a running up-to-date Ubuntu/Linux system. I am using Ubuntu 14.04 LTS 64-bit. I am running this in a Virtual-box over Windows and it is working fine for me. You can find simple guides on how to setup your Virtual-box on Google. I recommend using at least 100 GBs of hard drive space.

Use the built in terminal to make the steps. A terminal window can be opened by pressing Ctrl+Alt+T. Every single command for the terminal is marked with a $ sign. Just paste every command (without the $ sign) to your terminal window and there shouldn't be any problem.

IMPORTANT: INSTALL EVERYTHING AS A NORMAL USER. DON'T INSTALL AS ROOT!

2. Install the required packages to build (Ubuntu 14.04 LTS 64-bit)

Install packages:

$ sudo apt-get install bison build-essential curl flex \
g++-multilib gcc-multilib git-core gnupg gperf \
lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev \
libesd0-dev libncurses5-dev libsdl1.2-dev \
libwxgtk2.8-dev libxml2 libxml2-utils lzop \
openjdk-6-jdk openjdk-6-jre pngcrush schedtool \
squashfs-tools xsltproc zip zlib1g-dev

3. Install & setup java

You need a version 6 Java Development Kit for building Paranoid Android. Usually, the SUN JDK 6 is recommended. But there is another way: you can use the OpenJDK 6. When you installed the required packages as described above, you will just need to configure your Java installation. I use OpenJDK6 and it is working just fine!

Check your Java version:

$ java -version

Verify the symlinks. Javac, Java, Javaws, Javadoc, Javah, Javap and Jar should all point to the right Java location and version:

$ ls -la /etc/alternatives/java* && ls -la /etc/alternatives/jar

If they are pointing to the wrong versions you have to change that to OpenJDK6.

Select the default Java version for your system:

$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javaws
$ sudo update-alternatives --config javadoc
$ sudo update-alternatives --config javah
$ sudo update-alternatives --config javap
$ sudo update-alternatives --config jar

That's it.

4. Repo and sources

Install repo:

Repo is a tool that makes it quite easy to download and maintain the sources of Paranoid Android.

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

Create the working directory:

$ mkdir ~/paranoid
$ cd ~/paranoid

Initialize Repo:

$ repo init -u git://github.com/AOSPA-legacy/manifest.git -b kitkat

Here you will probably get an error. You have to enter your credentials

Run these two commands to setup your crendentials.

$ git config --global user.name "Your Name"
$ git config --global user.email your@example.com

Setup sources:

Now you will download the source code.

$ repo sync

You can make some customizations to these commands, for example you can download more items parallel. Of course this will take more bandwidth so it’s up to you.

$ repo sync -h
Usage: repo sync [...]

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

repo Version options:
--no-repo-verify do not verify repo source code

So for example if you want to fetch 10 jobs at the same time use this command.

$ repo sync -j10

Wait until it's finished - takes some time to download the hefty 12 GB of source code!

Take a break, have a KitKat!

If the process hangs use Ctrl+C to break out of it and resume the download with another

$ repo sync

If you are running into a lot of syncing errors the reason might be that the 'repo sync' command is establishing four threads automatically. This might be too much. So try to change the command to run with one thread only by using

$ repo sync -j1

5. Building the ROM

Turn on caching to speed up your build.

You can speed up subsequent builds by adding

export USE_CCACHE=1

to your ~/.bashrc file.

To access this file run the following

$ gedit ~/.bashrc

Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:

prebuilts/misc/linux-x86/ccache/ccache -M 50G

where 50G corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you're only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration.

You have all the standard sources ready but some specific sources for your device are still missing. Luckily they will be downloaded when you start to build your rom. Again be sure to be in your top directory.

Now build it:

$ ./rom-build.sh honami

And the building process starts. First it creates a new manifest called roomservice.xml then it downloads the device specific kernels and such.

If it gives you an error, try to CTRL+C and run repo sync. Then re-do the previous step.

Now it’s time to practice your patience again, the first build will take a long time. A couple of hours depending on your machine setup.

When everything worked as it should you will find your new ROM-image in ~/paranoid/out/target/product/honami

It is called pa_honami-4.4-BETA x-DATE .zip You can flash it via CWM/TWRP as usual.

6. Renew sources and build again

Whenever you like to update your sources and build a new version you have to run these four simple commands:

$ cd ~/paranoid
$ repo sync
$ ./rom-build.sh honami

Compiling takes less time than it took for creating the ROM the first time because it's only building new parts while reusing old parts that haven't changed.

Good luck and have fun while building!

CREDITS AND THANKS TO:

Raum1807 for his awesome cm11 guide, I used that as a template.

SuperHanss

gokussjx

Pirateghost

SferaDev

MasterAwesome

Paranoid Android TEAM

CM TEAM

Please pm me if i forgot someone or if have to take this down!