0% found this document useful (0 votes)
349 views74 pages

Android Rom Dev 1.1

This document provides a 10 step guide for setting up an Ubuntu 16.04 LTS environment to compile Android ROMs. The steps include installing necessary build tools, downloading the Android source code using the repo command, and setting up Java. Key steps include using the repo command to initialize and sync the Android source code, choosing an Android version branch like CyanogenMod 13, and installing the appropriate Java version like OpenJDK 7 for older ROMs. The guide is intended for beginners building ROMs for the first time.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
349 views74 pages

Android Rom Dev 1.1

This document provides a 10 step guide for setting up an Ubuntu 16.04 LTS environment to compile Android ROMs. The steps include installing necessary build tools, downloading the Android source code using the repo command, and setting up Java. Key steps include using the repo command to initialize and sync the Android source code, choosing an Android version branch like CyanogenMod 13, and installing the appropriate Java version like OpenJDK 7 for older ROMs. The guide is intended for beginners building ROMs for the first time.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

Let’s DO A SMALL REVIEW FIRST

What is Android Open Source Project?

• Maintained by Google • Contributions accepted

• Provides templates for building an Android system

• Provides the complete source code (but usually missing


proprietary binaries) for a brunch of supported devices (e.g
Google Nexus, Android Emulator...)
Why we use these projects instead of Android Open Source Project
• Easy to build for newbie
• Custom distros offer more functions
• Easy to customize

Tips and tricks


• VIRTUAL BOX 32 or 64 bit (enable virtualization)
• Need up to 250GB for a wonderful single build, and 200GB or
more for multiple builds if downloaded the repo. With ccache
enabled, you will need even more space.
• 16GB RAM + 8GB swap is enough but 16GB RAM is recommend •
Consider upgrade PSU & HSF
•Note: Internet connection required at least 100GB of data
(normal ISP OR A VPS[virtual private server] )
[HOW TO] Setup Ubuntu 16.04 LTS Xenial
Xerus to Compile ANDROID ROMS

With a new version of Ubuntu comes an update to my guide for setting up a build environment to
compile Android ROMs. The aim of this is to simplify the configuration process and teach a
little bit about the command line. It’s ten easy steps! Of course, this could be boiled down to a
two-liner with some CLI wizardry, but that isn’t the point.

Follow the directions in order. Copy and paste the code, or better yet, type it out for an improved
learning experience.

This guide applies to all variations of Ubuntu 16.04 LTS Xenial Xerus 64 bit. Do not use the
32 Bit version.

Also, PAY CLOSE ATTENTION when to use “sudo” and when to not.

Much thanks goes out to Google, ProTekk, Canonical, and everyone else that I read a random
paragraph here and snippet there.

1) Unless it’s a completely fresh Ubuntu installation, the wrong version of Java might be
installed. Let’s fix that first.

The command below makes sure you’re starting with a clean slate. Copy and paste it into a
terminal (command prompt) window:

sudo apt-get remove openjdk-* icedtea-*

If necessary, follow the on-screen instructions to remove any stray Java versions. Otherwise,
move on to the next step.

2) Install the main build tools with this command:

sudo apt-get install git ccache automake lzop bison gperf build-essential zip
curl zlib1g-dev g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev
libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev
liblz4-tool make optipng maven libc6-dev linux-libc-dev gcc-multilib g++-5-
multilib libssl-dev
3) “repo” communicates with git servers for all that precious source code. The next command
will grab it:

mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-


downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

4) Use a favorite text editor to open ~/.bashrc (or equivalent) – nano is easy to use:

nano ~/.bashrc

5) At the very bottom (use the Page Down key) paste this code to a new line:

export PATH=~/bin:$PATH
export USE_CCACHE=1

6) Save it. In nano that would be Ctrl-O and then Enter. Then Ctrl-X to exit back to a prompt.
Restart the shell:

source ~/.bashrc

7) In the terminal, make a folder to download the Android source code. The commands below
will keep it in the home directory, but if limited on space it’s ok to create it somewhere else.
Faster is better, i.e. NVMe would be best, USB (even 3.0) will be comparatively slow. Here we
go:

mkdir ~/android
cd ~/android

8) Now initialize the repo. Decide the flavor of Android to build, i.e. AOKP, CyanogenMod,
AOSP etc. For the purposes of this tutorial, here’s the command for Cyanogenmod 13
(Marshmallow) :

repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0


9) Time to get the source, many gigabytes of downloading await. Don’t worry, it’s automated.

repo sync

Check back periodically every hour or so. It all depends on how fast the connection is.

10) Now, for Java. Some ROMs (Android Lollipop / CM 12.1 and below) require OpenJDK 7.
Marshmallow / CM 13 and above require OpenJDK 8. If building for reallllllly old devices,
OpenJDK 6. Here’s the easiest way to install on Ubuntu 16.04.

Add the PPA for OpenJDK:

sudo add-apt-repository ppa:openjdk-r/ppa

Then, install the appropriate version of Java. In this case we’re going to use 7, because it’s
popular. Simply replace openjdk-7-jdk with 6 or 8 as needed.

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

That’s it! Everything should be ready to go.

[HTTP://SPEEDDEVS.BLOGSPOT.COM OR http://SPEEDEVS.CF

IF YOU HAVE COMPLAINS OR A WAY TO IMPROVE ON THIS SITE CONTACT ME ON +2347053028992 OR


ON TELEGRAM WITH THE NUMBER ABOVE.

THANKS TO YOU ALL READIG THIS GUIDE GOD BLESS YOU ;

YOU CANA LSO VISIT MY CHURCH WEBSITE @ HTTP://WWW.SMHOS.ORG

(NOTE: I DON’T OWN THIS SITE: smhos.org) LOL

]
I am writing this tutorial together in an attempt to help beginners which are trying to
build a ROM from source for the first time.I faced many problems when I started
building roms, so I thought it will be better to help someone who is trying the same
thing.I have tried to make this guide easy to understand.Please feel free to PM if you
have any doubts!!
And if you built a rom by following this guide then please press the thanks button, it
will motivate me.

For Whom This Guide Is For


1. Who do not have a PC which meets required requiements for building a rom
2. Who cannot download the sources which might be up to 10GB
3. Who is building a rom for the first time

Prerequisites
1. Android Phone
2. A decent internet connection
3. A debit/credit card
4. Brain (OF COURSE)

Contents
1. Making a Google Cloud Account
2. Setting up the VM (Virtual Machine) on your phone
3. Setting up the build environment
4. Initializing and syncing the repo
5. Cloning the device,kernel and vendor tree
6. Building the rom
7. Uploading the ROM in Google Drive

1. Making A Google Cloud Account


NOTE:You will need a credit/debit card for making an account and it is free to use Google
Cloud for one year only.

STEP 1:Open Google Cloud from here.


STEP 2:Click on Free Trial

STEP 3:Login with your Google account username and password.


2. Setting up the VM (Virtual Machine) on your phone
STEP 1:Download Juice SSH app from here.
(NOTE: the JUICE SSH pro is recommended you can get the mod apk or support the company
by buying their software)
STEP 2:Open Juice SSH app and click on "Connections".
STEP 3:Navigate to "Identities" and create a new identity by pressing the "+" button.
STEP 4:Input the "Nickname","Username" (You can enter your name also in both places) and
then click on "Private Key"(Set (Optional) button). Navigate to "Generate" and press OK and
click on the tick icon.
STEP 5:Now long press the identity you just created and click on "Export Public Key" and click
on ES Note Editor or Keep (You need any one of them) and replace the "JuiceSSH" written at
the end with your username you entered in the identity and now copy the whole text.
STEP 6:Open Google Cloud and navigate to Computer Engine->Metadata->SSH Keys. Click on
edit and then add item.Paste the text you just copied and save it.
STEP 7:Navigate to Computer Engine->VM Instances. Click on "Create Instance".Enter the
name(Any name).Select Machine Type as "4vCPU". Select Boot Disk as "Ubuntu 16.04 LTS"
and set the size to 1000GB.Tick both "Allow HTTP traffic" and
"Allow HTTPS traffic" and click on create.
STEP 8:Now it will take a minute.After it is created copy the External IP.
STEP 9:Now open Juice SSH app and navigate to "Connections" and create a connection by
clicking on the "+" icon.Input the nickcname you entered while creating the identity.Paste the
External IP in the "Address" column and click on the tick icon.
STEP 10:Now click on the connection you just created. This will open the terminal on which
you need to work.

3. Setting up the build environment


NOTE:You just need to copy and paste the below codes one by one.

1. sudo apt update


2. sudo apt upgrade
3. sudo apt-get install git-core
4. git clone https://github.com/akhilnarang/scripts
5. cd scripts
6. bash setup/ubuntu1604linuxmint18.sh
7. mkdir -p ~/bin
8. mkdir -p ~/android/lineage (Replace lineage with your rom name or you can also use lineage
for any rom for easy to understand))
9. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
10. chmod a+x ~/bin/repo
11. cd ~/android/lineage

4. Initializing and syncing the repo


1. repo init -u https://github.com/LineageOS/android.git -b cm-14.1

NOTE:Here I am compiling lineage os 14.1 therefore I am using it's repo initializing command.
You can find repo initialization command for your rom by the following method:
(i) Google search "rom_name github" (Replace rom_name with your rom name)
(ii) Open the rom github in dextop mode.(Use Google Chrome)
(iii)Click on the "manifest" or "android_manifest"
(iv) Select the branch which you want to build and copy the repo initialization command given at
bottom.

Some repo initialization commands:


(i). repo init -u https://github.com/ResurrectionRemix...m_manifest.git -b nougat
(ii). repo init -u https://github.com/AICP/platform_manifest.git -b n7.1
(iii). repo init -u git://github.com/CandyRoms/candy.git -b c7.1.2
(iv). repo init -u https://github.com/BlissRoms/platform_manifest.git -b n7.1

2. repo sync -j8

Go get a coffee till the source is syncinc. It will take time depending on your internet speed.

5. Cloning the device,kernel and vendor tree


1. git clone device_tree_link_here -b branch_name_here
device/manufacturer_name_here/device_name_here
Eg: git clone https://github.com/LineageOS/android...iaomi_mido.git -b cm-14.1
device/xiaomi/mido
2. git clone kernel_tree_link_here -b branch_name_here
kernel/manufacturer_name_here/chipset_name_here
Eg: git clone https://github.com/LineageOS/android...mi_msm8953.git -b cm-14.1
kernel/xiaomi/msm8953
3. git clone vendor_tree_link_here vendor/manufacturer_name_here
Eg: git clone https://github.com/TheMuppets/propri...dor_xiaomi.git vendor/xiaomi

NOTE:1.To find device tree link follow the following steps:


(i)Google search "Device_name device tree github"
(ii)Select the branch and copy the device tree link.
2.To find the kernel tree link follow the below steps:
(i)Google search "lineage os github".
(ii)Input your chipset name in the search box and select the repository for your device.
(iii)Copy the link.

3.To find the vendor tree link follow the below steps:
(i)Google search "The Muppets Github".
(ii)Find the repository for your device and copy the link.

If you can't find any tree with the above methods, then simply google search that tree for your
device!!!!

6. Building the rom


1. export USE_CCACHE=1
2. prebuilts/misc/linux-x86/ccache/ccache -M 50G
3. export CCACHE_COMPRESS=1
4. . build/envsetup.sh
5. brunch device_name_here
or
5. make bacon -j8

Now it will take approx 7-8 hrs or more depending upon your internet speed.Go get a sleep till
then.

7. Uploading the ROM in Google Drive


1. cd ~
2. wget https://docs.google.com/uc?id=0B3X9G...xport=download
3. mv uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive
4. chmod +x gdrive
5. sudo install gdrive /usr/local/bin/gdrive
6. gdrive list
7. cd out/target/product
8. ls
Check your ROM name.
9. gdrive upload same_rom_name_here
Now it will show a link. Click on it and copy the code and paste it in the terminal.
Now your rom will start uploading in your Google Drive.

Congratulations You Built Your First ROM!!


Credits
THE DEV IN XDA THAT POSTED IT ;-)
WITH YOUR TEAM IF YOU HAVE GIVE
THEM SPECIAL CREDITS

What is MD5 and how to use it to verify your download


You have probably seen these below the rom or file you are downloading:
MD5: 4576d484f39792ab0cfb506ea0592150

So what is MD5? MD5 is a number used to make sure two files (yours vs theirs) are the exact same using
a mathematical equation. When you download, while the music industry likes to claim that digital
downloads are all exactly identical, the truth is, they aren't always. The internet sends everything in bits
and parts. Sometimes things get lost along the way. MD5 is used to make sure the files match. It's not just
the internet though, many don't realize a file can be corrupted any time it is moved (or even while sitting
on your hard disk if it's bad). This includes moving from your computer to the phone, since USB is far
from perfect.

So how do we use it?


We need a program that will generate an MD5 sum.
Personally, I use a portable one, meaning it doesn't install anything, it runs from a folder, or thumbstick.
You can move it where you like without it breaking.

This is what I use.


WinMd5Sum Portable | PortableApps.com - Portable software for USB, portable and cloud drives

How to check an md5.


Run the installer and tell it a folder to use, your desktop is fine.

Open the folder and run the program.

You should end up with a small little window. Drag the file you want to check onto that window.
The middle line will show you the md5 of your file.

Now, instead of looking at both numbers, copy the md5 the author gave you and past it in the bottom row
of that little window, and press compare. It will tell you if they match or not. If they don't then your file is
corrupt and you need to download it again.

MINIMUM REQUIREMENT FOR ROM COMPILING

Establishing a Build Environment.

• A 64-bit Linux or Mac OS System, recommend Debian-base Linux like Ubuntu,

• At least 16GB of RAM and extra virtual memory 4gb extra v.ram(virtual ram)

• 100GB or more disk space (recommended 1TB(terabyte)…

• Recommend Quad core CPU (More threads help build faster) • Builders can be share between
developers. OR an Intel XEON Recommended.

LETS ASSUME YOU KNOW WHAT STOCK ROM AND CUSTOM ROM IS

WHICH IS STOCK ROM IS THE FACTORY BUILT MADE ROM FOR THE PHONE.

WHILE CUSTOM AS THE NAME IMPLIES IS EITHER PORTED OR BUILT FOR A PHONE..
:-)

Credit’s
Michael(smhos.org) in xda (me)

Please donate to my bitcoin address,


Buy me a coffee

12e4FpWQQyan6v9Ywk6HTN6Pc1TXYzbneP
COMPILING REDMI ROM
So now, getting to work
First of all you will be need some git basics and you should be familiar with
linux and its commands

I will give an example using Redmi 3 (ido) device

The kernel source be found


https://github.com/MiCode/Xiaomi_Kernel_OpenSource/tree/ido-l-oss
So fork it to your GitHub account, or clone from micode and push to your git
account. (if you want to)

So start off, by installing all dependencies which is needed for kernel


compilation. Look here https://github.com/akhilnarang/scripts and please
read readme for installing deps.

Now open terminal and put this

git clone https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b ido-


l-oss ido-kernel

This command will fetch kernel source to your pc.

Now, all kernel source's have a file called a defconfig, or default


configuration, that is device-specific

You will find it in arch/*your devices architecture*/configs

Your device may be arm, arm64, x86, in case our one is arm64. So defconfig
placed on arch/arm64/configs

Make sure you remember the name of the defconfig, you can rename it too.
Our defconfig name is wt88509_64-perf_defconfig
If you would like to give your kernel a name, simplest way would be to look
for the CONFIG_LOCALVERSION in the defconfig

Make it something like


CONFIG_LOCALVERSION="-Your-Kernel-Name"

Anyway, so now you need a toolchain

For starting off, we will use GCC 4.9 from Google

For aarch64/arm64 devices

git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-


x86/aarch64/aarch64-linux-android-4.9

Now remember where you saved it

Now open the file called "Makefile" in the root of kernel source

Look for a line that has ARCH?=


that dosen't start with a # (lines starting with # are comments)
ARCH ?= arm64
SUBARCH ?=arm64
And look for CROSS_COMPILE ?=
make it
CROSS_COMPILE ?= path/to/downloaded/toolchain/bin/aarch64-android-
linux-
for arm64 devices
This should be like
CROSS_COMPILE=/home/anik/kernel/aarch64-linux-android-
4.9/bin/aarch64-linux-android-
This may differ on Custom toolchains, etc, you can find out about that by
viewing the commits of different kernels, and going through various threads
I'm only gonna explain how to compile the kernel, not how to add stuff (at
least for now)

Enter to your kernel directory and run


make wt88509_64-perf_defconfig

That's what my defconfig is called, yours maybe called something else


And now finally to start the build

First, check how many cores/threads your CPU has


A quad core Intel, an octa core AMD, will have 8
So if you have one, run
make -j8
This will compile the code on all 8 threads parallely
However this makes debugging errors harder
If you have an error, just run
make
to reduce output and identify error
Anyway, the process generate a zImage in arch/arm/boot/zImage
or arch/arm64/boot/zImage
This is a binary file.

If you want to make boot.img with your compiled kernel then you have to
follow this:

Extract you stock boot.img from your device and the unpack it using
mkbootimg tools. Here you will find

https://github.com/xiaolu/mkbootimg_tools

Rename your zImage to kernel and replace with extracted kernel. Then
repack boot.img and flash.

If you don't understand any of these terms , please google about them first,
and then if you are unable to find out ask here please.

Enjoy
:-)
ERROR AND SOLUTION IN COMPILING ROM
Make failed to build some targets
After syncing the repo, a file called repo_update.sh is symlinked in the root directory, and it applies some
patches which correct this and various other issues (this is the new method, previously Sony had these
patches on the instructions page, see here for more info). Everything compiles 'fine', but my phone
(F5121) goes into a bootloop after flashing. I'll post the log later on; most of the errors are audio related,
but I don't know if that's the root cause yet.
Can confirm repo_update.sh resolves Make errors

linker command failed with exit code 1 (use -v to see invocation) can any one help
me to solve this
Check your header and how you start to compile rom and the following

1) if you had two same constants in different classes then also this issue happens.

2) if you have accidently imported a .m file instead of .h file in an implementation file.

3) This error can also be occurred if you have imported two different versions of same library ,in this
case just remove the older version and keep only one version.

4) Adding the "other linker flags" in "Project" and not in "Targets". So, you move it to "Targets", it
shouldn't be in "Project".

5) Check it out in project->target->build settings-> search enable bitcode->set NO in DEBUG

check out this .. if it's OK then once do like following.

Menu > Product > Clean ... then Run the project

Hope it helps you.. :)

Easiest way to setup build environment ?


Answer: Their is a script will will make all the work easy by Akhil Narang XDA senior Member and great
dev
Steps to be followed:

git clone https://github.com/akhilnarang/scripts

cd scripts

bash setup/<name of script>

Which is the best distro to build custom rom?


Answer: I will always recommend to use Ubuntu
If I have low internet speed how to sync sources that too 60Gb and all?
Answer: Use Google cloud Platform which is the best because internet speed syncs source within half an
hour build speed max 2hour first build then less than 30mins or Amazon Aws, then last option is Digital
OCEAN.

Is any programming language required to study while building ROMs?


Answer: Absolutely No since for making roms from source you just require BASIC English thats it and
few logic how does fuctions work etc.,But to know you need to know BASH, GIT and LINUX the backend.

I have MacBook can I built on it since it is having BASH terminal?


Answer:Sure you don’t need to install another distro inbuilt Mac OS is enough.

I have a windows I don't want to use any trial VPS(VIRTUAL PRIVATE SERVER)
and don't want any distro as secondary OS.

No problem you can use virtualbox to run Linux for free, Just need your space and
stable internet connection. and also if you don't need it you can just create and install un

While building it stopped what to do ?


Answer: Simplest way is copy whole data and paste in any IDE and search for “FAILED:” line and read it
understand what made wrong then google how to fix it,Few common errors and their fixed are their below
just bookmark if you need.

I Googled still not found a solution how to fix it ?


Answer: Their are many ways ask on XDA else you get contact with developer of that rom message him
and resolve it.

What is Cherry-picking is please explain?


Answer: It is actually taking a feature of one rom and then add to your rom by giving proper credits to
author etc.There is a good tutorial for doing this refer to this
How to apply patches to the source ?.This will surely help you a lot.

Is there any place where I can get full details of rom files folders etc ?
Answer: Yes there is an awesome post explaining everything.

I have one commit which is commit but I need to add proper author to it what to
do?
Answer:
git commit –amend –author=”NAME ”
This will add author to last commit

I have done changes I need to overwrite the commit its not allowing asking for
pull and retry like that.
Answer: do same git push command just add ” -f ” tag so it overwrites the git.
for e.g.: ” git push GitHub 7x -f “instead of “git push GitHub 7x ”

Any Simple way to resolve conflicts while cherry-picking ?


Answer: The best way is to use search tool and search for “>>>”,”<<<“,”===” remove, add keep both
depending on code.Second Method is by using GitHub as search.

Is there any simpler way to check cherry-picked correctly or not since building
whole ROM takes time.
Answer: Build only the required package to check if it worked correctly then build Rom as whole .For e.g.
you made changes to kernel and device tree in that case just use time mka boot image rather than time
mka bacon.

How to remove snap camera from building?


Answer:Remove Snap from BoardConfig and use zip contents and manifest to see what permissions to
do, use PRODUCT_COPY_FILES command

How is flashable ZIP of kernels made?


Answer:Android zips have updater-script which is programmed in edifier,You basically need to make a
flashable zip which would write boot.img into /dev/block/bla/bla/boot.

Should I dexpreopt my builds?


Answer: Not necessary it is just first boot speeding up and take extra size around 100mb more.

What does boot.img contain?


Answer: it has kernel and ramdisk

What are BLOBS?


Answer: Blobs are vendor files and prebuilt libs which are found in system, importing them is copy paste
+ the mk file, It’s usually found in /system/vendor and /system/lib.

Common Errors:

All these erros I mention are faced by me and solution which I did is written along.
#1:
libwpa_qmi_eap_proxy_
intermediates/export_includes’, needed by
‘/home/vibhoothiiaanand/nuclea/out/target/product/oneplus2/obj/EXECUTABLE
S/wpa_supplicant_intermediates/import_includes’, missing and no known rule to make it
make: *** [ninja_wrapper] Error 1
Solution:
First check wheather your vendor repo is broken or not or is it included or not if not clone it from correct
source.
Clone wpa supplicant ,wpa_supplicant8 from lineageos and retry it

#2:Build is successful but its not booting what to do?

Solution:
Make another build with permissive by adding
“androidboot.selinux=permissive” to BoardConfig.mk it should work.

#3:I have synced device tree but device is not showing in breakfast nor lunch
menu

Solution:
1.first change romname.mk file to your rom name ,for e.g. you synced Du tree and trying to make nitrogen
rom so mv du.mk nitrogen.mk.
2.Change vendorsetup.sh make appropriate name of device name with rom.
3.Change .dependencies name to rom name for e.g.. du.dependencies make it nitrogen.dependencies
4.Make AndroidProducts.mk and call device.mk from it.
Will show you how things are done.
Oneplus2 device tree modded for supporting VertexOS: Vertex-fy
Oneplus2 device tree modded for supporting Candy Rom :Candify
there will be so much commits like this just git search then your good to go.
This must be general case for most of the rom and devices just refer this.

#4:
ninja: error:
‘/home/vibhoothiiaanand/nitrogen/out/target/product/oneplus2/obj/SHARED_LIBRARIES/libqdutils_interm
ediates/export_includes’, needed by ‘/home/vibhoo
thiiaanand/nitrogen/out/target/product/oneplus2/obj/SHARED_LIBRARIES/libsurfaceflinger_intermediates
/import_includes’, missing and no known rule to make it
make: *** [ninja_wrapper] Error 1
Solution:
this is common error and its due to missing hardware BLOBs so to fix this there are few things to clone
these files are to cross checked if not clone from lineage
hardware/qcom/display
hardware/qcom/display-caf
hardware/qcom/audio
hardware/qcom/audio-caf
hardware/qcom/media
hardware/qcom/media-caf
hardware/qcom/bootctrl
hardware/qcom/bt
hardware/qcom/bt-caf
hardware/qcom/camera
hardware/qcom/gps
hardware/qcom/wlan
hardware/qcom/wlan-caf
hardware/qcom/keymaster
and for cloning I will show you how its done for Oneplus2
git clone https://github.com/LineageOS/android_hardware_qcom_display.git -b cm-14.1
hardware/qcom/display/msm8994
git clone https://github.com/LineageOS/android_hardware_qcom_audio.git -b cm-14.1
hardware/qcom/audio/msm8994
git clone https://github.com/LineageOS/android_hardware_qcom_media.git -b cm-14.1
hardware/qcom/media/msm8994 git clone
https://github.com/LineageOS/android_hardware_qcom_display.git -b cm-14.1-caf-8994
hardware/qcom/display-caf/msm8994
git clone https://github.com/LineageOS/android_hardware_qcom_audio.git -b cm-14.1-caf-8994
hardware/qcom/audio-caf/msm8994
git clone https://github.com/LineageOS/android_hardware_qcom_media.git -b cm-14.1-caf-8994
hardware/qcom/media-caf/msm8994
#5
device/generic/goldfish/data/etc/apns-conf.xml’, needed by
‘/home/vibhoothiiaanand/nitrogen/out/target/product/oneplus2/system/etc/apns-conf.xml’,
missing and no known rule to make it.

Solution:
just clone generic/goldfish from google since its old AF in lineage source
git clone https://android.googlesource.com/device/generic/goldfish device/generic/goldfish

#6
frameworks/native/build/phone-xxxhdpi-4096-dalvik-heap.mk” does not exist. Stop.

Solution:
Fix is just cherry-pick this commit
https://github.com/CyanogenMod/android_frameworks_native/commit/6500d428ce816ffa0ba099221a498
7ad7bfcb4ab
Done it must be fixed

#7
ERROR: couldn’t find ro.product.model in build.prop

Solution:
This is not that common but this happens while compiling
fix is cherry-pick this commit
https://github.com/AICP/build/commit/df574f3e6ae115425b2c25e5b5e6772503ca0f65

#8
Model number unknown.

Solution:
Go to device tree and open init/init*.cpp make device name and instead of std::string device =
property_get(“ro..device“); change to std::string device = property_get(“ro.product.device“);

#9
Deleting obsolete path /home/vibhoothiiaanand/vertex/device/oneplus/oneplus2
Deleting obsolete path /home/vibhoothiiaanand/vertex/device/oppo/common
Deleting obsolete path /home/vibhoothiiaanand/vertex/kernel/oneplus/msm8894
Deleting obsolete path /home/vibhoothiiaanand/vertex/vendor/oneplus

Solution:
this is due to not declaring repos in local manifest
#10 Broken gestures
for this two things must be noted kernel and device common must match the node names in case of
oneplus2
in kernel: drivers/input/touchscreen/synaptics_driver_s3320.c and
configpanel/src/com/cyanogenmod/settings/device/utils/Constants.java should match node declaration
values

#11 Dex2oated errors


it usually look like this
2017-06-04 22.39

For this easy fix is disabling dexpreopt

#12 ninja: error:


‘/home/vibhoothiiaanand/vertex/out/target/common/obj/JAVA_LIBRARIES/rcscommon_intermediates/java
lib.jar’, needed by
‘/home/vibhoothiiaanand/vertex/out/target/product/oneplus2/dex_bootjars/system/framework/arm64/boot.
art’, missing and no known rule to make it
make: *** [ninja_wrapper] Error 1
make: Leaving directory `/home/vibhoothiiaanand/vertex’
For me this happened while building vertex for that I removed telephony entry from
android_vendor_vertex/config/common.mk

#13 /out/target/product/oneplus2/obj/SHARED_LIBRARIES/libdhcpcd_intermediates/export_includes’,
needed by
‘/home/coolmohammad98/cr/out/target/product/oneplus2/obj/EXECUTABLES/ipacm_intermediates/

Solutions
For this clone https://github.com/lineageos/android_external_libnfnetlink and then your good to go

Thanks to MZO for helping out..)


AOSP Build not booting on hammerhead

FIXED BY deploying vendor binaries into the android source tree from google page

It is quite easy, You download the zip files and run them in the source tree root. They append
additional software being embedded int the final img files of the built system. Rebuild after this
takes about 2 mins, because all android build system does is repackage the imgs .
e.g
So finally, got the problem. Actually I pulled the android branch and was using google's preview
binaries.

Then I pulled the android-4. branch and used Google Binaries for android 4.4.4_r2. Everything
went fine.
How to Build an Android ROM

What follows is more a simple explanation on how to build an Android ROM. I’m going to
discuss several parts that can’t be absent if you want a fully functional Android phone,
from the software point of view that is.

Here’s a brief summary :


•Kernel

•Libraries (and modules)

•Bootloader

•Recovery

•Radio

•Apps, framework, core, android-runtime, etc…

Kernel
A kernel is a critical component of every Operating System. It can be seen as a sort of bridge between
the applications and the actual hardware of a device. Usually the data processing part is done at
hardware level, furthermore the kernel is the most low-level abstraction layer for theresources.

There exist several types of kernels, but I am only discussing the one that is important for the Android
ROM. The kernel for the Android ROM is a hybrid kernel, it is based on the Linux kernel. Devices can
differ in RAM memory, ROM memory, hardware parts and so on. So it’s really important you have a
kernel for your type of device, an HTC Wildfire kernel won’t work on a Nexus One for example.

It is possible to overclock a kernel. You may wonder, what the hell is overclocking? Every CPU is
designed to work at a certain clock speed. For the HTC Wildfire the Qualcomm ARMv6 processor
operates at 528 mHz — this is a limit that is coded in to the kernel because they can’t guarantee good
cooling for the CPU if you go over this limit. My Wildfire runs at 652.8 mHz and it can go to 768 MHz until
it freezes. When you overclock the kernel, the CPU will be instructed to do more calculations per second;
so, it will increase performance.

When you overclock the CPU of your desktop machine, it will need extra cooling, but fortunately that’s not
necessary for a smartphone. However, keep in mind that this will degenerate your CPU much faster than
if it was at stock. To overclock an Android phone you must root it and install SetCPU or another
overclocking app from the Play Store. Then you will have to flash a kernel that supports overclocking. I
prefer the OC Kernel of HCDR.Jacob, at XDA-forums (see links right). If you have done these 3 things
you’re ready to OC!

Libraries
Imagine you want to program an application for your phone that uses the camera. It can take a picture
and turn the flash LED on. These are things not only your own application will use, but there can be tons
of applications that have a button that can take a photo. So, imagine those apps always having to write
the machine code to get the camera to turn on; it would be a lot of code duplication and would make an
application slow. Instead, for functions like the camera or loudspeakers, they developed libraries. These
are chunk of codes that can be executed by calling them trough a call-method (in java : import
somelibrarie.someclass;). These are already pre-written and ready to use. It saves a lot of coding work
and keeps the source code small. Libraries in the Windows OS for example are called .dll files (Dynamic
Linked Libraries), whereas on your Android ROM or Linux OS these are the .so files (Shared Object).
When coding in Java you import .jar libraries before the class signature. On your Android phone you have
particular libraries that can’t be absent, or else your ROM won’t even boot.

Bootloader
A bootloader in general is the first bytes of code that a machine executes that will tell the bootsequence
and will load the operating system into the RAM. On an Android phone this is the so called HBoot. From
here you can go to the recovery, system or data partitionn. By pressing the power button on your phone,
HBoot will load the OS into RAM. By pressing the power and volume down buttons, you’ll bring up the
HBoot menu.

The bootloader is used as an exploit for rooting an Android phone. Once rooted you can flashcustom
ROMs, like ImPrOS, or just edit system files (for a how-to, check tutorials under Android.)

Recovery
When you use a one-click-root application like Unrevoked3, it will install a modded recovery. With this
modded recovery it is possible to flash a new kernel, radio image (see below), customROM, install
applications (not the best way though), Nandroid backup, etc. The moddedrecovery that is flashed by
Unrevoked3 is called ClockworkMod.

Recovery is a method for you to not only save yourself when you screw up (which you will! ), but to
update the ROM or kernel that’s on your phone, partition your SD card to use with a2sd, and many other
OS-related things. There’s a lot of different recoveries for different phones, so you’ll have to do some
research of your own into what the most respected one is for your phone. The recovery is essential,
because you want to always have a fallback in case something bad happens to your phone’s software.

Radio
The lowest part of software layer is the radio: this is the very first thing that runs, just before
thebootloader. This handles the GPS antenna, GSM antenna and fires up the CPU; everything that HBoot
needs to load the OS. This can also be upgraded by flashing a new radio image through your recovery.
However, this is not recommended: flashing a new ROM can’t brick your phone (make it unusable), but if
anything goes wrong when you flash a ROM with a new radio image, this can brick your phone. So unless
you experience bad reception or battery drainage, don’t touch the radio!
A COMPLETE AND STEP BY STEP BY STEP GUIDE TO PORT/COMPILE TWRP
RECOVERY FROM SOUCE CODE IS HERE,
you must have some basic knowledge to Complete The Process,
Initial requirements:

1)Linux, I suggest Ubuntu 64bit

2)Focus, determination and To BE PATIENT.

3)A brain of course(YEP NEEDED )

Chapter 1: Setting up Build Environment

First requirement is Java. The version you need depends on what Android version you want to compile

Open the terminal and type: java -version


From Gingerbred to Kitkat you have to use openjdk 6
For Lollipop and MM you can use openjdk 7 or opendjk8

Notice: for openjdk8 before start the compilation with "make recoveryimage"
Type: export EXPERIMENTAL_USE_JAVA8=true and press enter.

Code:
If you have the wrong version type: sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
Follow the on-scren instructions to remove it.
Now install the jdk you need
For Openjdk 6

For Openjdk 7
Code:
Type the following commands:
sudo add-apt-repository ppa:openjdk/ppa
sudo apt-get update && sudo apt-get install openjdk-7-jdk
Next requirement are libraries and build tools
Open a fresh terminal prompt, copy and paste this:

Code:
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-
dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-
tools pngcrush schedtool dpkg-dev liblz4-tool make optipng
Now let's get a copy of "repo", it is a program that lets you communicate with git servers and download
the source code.

Code:
1)mkdir ~/bin -This command creates the bin folder that will contain the repo command

2) curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo -This command


downloads the repo command in the bin folder

3) chmod a+x ~/bin/repo -Give the repo command right permissions

4)sudo nano ~/.bashrc At the very bottom(Use page down key) add this line: export PATH=~/bin:$PATH
Then press Ctrl+O and Enter to save and Ctrl+X to exit.
After that type: source ~/.bashrc
-With these commands you add repo to .bashrc file that allows you to call the command from every path.

Chapter 2: Repo sync Android sources


At this point you are almost ready to compile whatever you want but first you need Sources.

These are divided in:


-Android base sources
-Device sources
Let's obtain the first one
If you want to compile ROMs such as CyanogenMod you MUST repo sync the entire sources but if you
want to compile only the TWRP recovery you CAN sync minimal sources

Full Sources
NOTICE: replace "BRANCH" with the version of android you want
Omnirom Sources
Available Android branches:

android-6.0
android-5.1
android-5.0
android-4.4
android-4.3
Open a fresh terminal and type the following commands.

mkdir ~/NameOfTheFolder It's your choice

cd ~/NameOfTheFolder

repo init -u git://github.com/omnirom/android.git -b BRANCH

repo sync -jN N=numbers of parallel downloads, it depends on your connection Example: repo sync -j2

CyanogenMod Sources on GitHub just search

Available Android branches:


cm-13.0
cm-12.1
cm-12.0
cm-11.0
Open a fresh terminal and type the followng commands.

mkdir ~/NameOfTheFolder It's your choice

cd ~/NameOfTheFolder

repo init -u git://github.com/CyanogenMod/android.git -b BRANCH

repo sync -jN N=numbers of parallel downloads, it depends on your connection Example: repo sync -j2

Minimal Sources
NOTICE: replace "BRANCH" with the version of android you want

Omnirom Minimal Sources available on Github

twrp-6.0
twrp-5.1
twrp-4.4

Open a fresh terminal and type the followng commands.

mkdir ~/NameOfTheFolder It's your choice

cd ~/NameOfTheFolder

repo init -u git://github.com/lj50036/platform_manifest_twrp_omni.git -b BRANCH

repo sync -jN N=numbers of parallel downloads, it depends on your connection Example: repo sync -j2

CyanogenMod Minimal Sources

twrp-13.0
twrp-12.1

Open a fresh terminal and type the following commands.

mkdir ~/NameOfTheFolder It's your choice

cd ~/NameOfTheFolder

repo init -u git://github.com/lj50036/platform_manifest_twrp_cm.git -b BRANCH

repo sync -jN N=numbers of parallel downloads, it depends on your connection Example: repo sync -j2

The download of the sources will take a bit ^


Device sources are divided in
1)Kernel
2)Device Tree
3)Vendors
Sorry, I can't help here cause every device has its own sources
For further information search if your device has sources or create one

NOTICE

If you repo synced CyanogenMod Full sources you don't have TWRP sources so go here, select the
branch you want and download it.

https://github.com/omnirom/android_bootable_recovery

Extract the archive in /home/username/NameOfTheFolder/bootable

Rename the folder to "recovery-twrp" without quotes ----> Warning: Be sure that in
NameOfTheFolder/device/vendor/devicename/Boardconfig.mk there is RECOVERY_VARIANT := twrp

Chapter 3: TWRP compilation


I'm going to use a device as example
Once you had your sources organised as follow:

/home/username/NameOfTheFolder/device/vendor/devicename
/home/username/NameOfTheFolder/kernel/vendor/devicename
/home/username/NameOfTheFolder/vendor/vendor/devicename

Device Tree
Kernel
Vendor files

Download and extract it in /home/username/NameOfTheFolder/device/vendor/ them rename the folder to


your devicename

Open a fresh terminal and type the following commands:

Code:
cd ~/NameOfTheFolder
source build/envsetup.sh
lunch
Type the number of your device and press enter. For example in my case the number 16 is my device
mka recoveryimage ---> This command will start the compilation of the recovery.

I hope I have been clear, Enjoy

THIS GUIDE IS BOTH for Newbie ANd PRofessionals

1. Who do not have a PC which meets required requiements for building a rom

2. Who cannot download the sources which their Pc cant carry rom compiling build or don't want
to install Ubuntu

3. Who is building a rom for the first time


Prerequisites
1. A Fast android PHONE
2. A stable internet connection, to see the build on sync repo and compiling

3. A debit/credit card
4. FOCUS,CHILL AND RELAX AND WISDOM(BRAIN)

Contents
1. Making a Google Cloud Account
2. Setting up the VM (Virtual Machine) on your phone
3. Setting up the build environment
4. Initializing and syncing the repo
5. Cloning the device, kernel and vendor tree
6. Building the rom
7. Uploading the ROM in Google Drive

1. Making A Google Cloud Account


NOTE: You will need a credit/debit card for making an account and it is free to use Google Cloud
for one year only.

STEP 1:Open Google Cloud from here, by visiting their website cloud.google.com

STEP 2:Click on Free Trial

STEP 3:Login with your Google account username and password.

STEP 4: filling in your billing details with your credit card info,(most time it will ask for
verification, verify it).

2. Setting up the VM (Virtual Machine) on your phone


STEP 1:Download Juice SSH app. download the pro of it to enjoy all the feautures,

STEP 2:Open Juice SSH app and click on "Connections".

STEP 3:Navigate to "Identities" and create a new identity by pressing the "+" button.

STEP 4:Input the "Nickname","Username" (You can enter your name also in both places) and then
click on "Private Key"(Set (Optional) button). Navigate to "Generate" and press OK and click on
the tick icon.
STEP 5:Now long press the identity you just created and click on "Export Public Key" and click on
ES Note Editor or Keep (You need any one of them) and replace the "JuiceSSH" written at the end
with your username you entered in the identity and now copy the whole text.

STEP 6:Open Google Cloud and navigate to Computer Engine->Metadata->SSH Keys. Click on edit
and then add item.Paste the text you just copied and save it.

STEP 7:Navigate to Computer Engine->VM Instances. Click on "Create Instance".Enter the


name(Any name).Select Machine Type as "4vCPU". Select Boot Disk as "Ubuntu 16.04 LTS" and set
the size to 1000GB.Tick both "Allow HTTP traffic" and
"Allow HTTPS traffic" and click on create.

STEP 8:Now it will take a minute.After it is created copy the External IP.

STEP 9:Now open Juice SSH app and navigate to "Connections" and create a connection by
clicking on the "+" icon.Input the nickcname you entered while creating the identity.Paste the
External IP in the "Address" column and click on the tick icon.
STEP 10:Now click on the connection you just created. This will open the terminal on which you
need to work.

3. Setting up the build environment


NOTE:You just need to copy and paste the below codes one by one.

1. sudo apt update


2. sudo apt upgrade
3. sudo apt-get install git-core
4. git clone https://github.com/akhilnarang/scripts
5. cd scripts
6. bash setup/ubuntu1604linuxmint18.sh
7. mkdir -p ~/bin
8. mkdir -p ~/android/lineage (Replace lineage with your rom name or you can also use lineage
for any rom for easy to understand))
9. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
10. chmod a+x ~/bin/repo
11. cd ~/android/lineage

4. Initializing and syncing the repo


1. repo init -u https://github.com/LineageOS/android.git -b cm-14.1

NOTE:
Here I am compiling lineage os 14.1 therefore I am using it's repo initializing command.
You can find repo initialization command for your rom by the following method:

(i) Google search "rom_name github" (Replace rom_name with your rom name)

(ii) Open the rom github in dextop mode.(Use Google Chrome)

(iii)Click on the "manifest" or "android_manifest"

(iv) Select the branch which you want to build and copy the repo initialization command given at
bottom.
Some repo initialization commands:
(i). repo init -u https://github.com/ResurrectionRemix...m_manifest.git -b nougat
(ii). repo init -u https://github.com/AICP/platform_manifest.git -b n7.1
(iii). repo init -u git://github.com/CandyRoms/candy.git -b c7.1.2
(iv). repo init -u https://github.com/BlissRoms/platform_manifest.git -b n7.1

2. repo sync -j8

Go get a coffee till the source is syncinc. It will take time depending on your internet speed.

5. Cloning the device,kernel and vendor tree

1. git clone device_tree_link_here -b branch_name_here


device/manufacturer_name_here/device_name_here
Eg: git clone https://github.com/LineageOS/android...iaomi_mido.git -b cm-14.1
device/xiaomi/mido

2. git clone kernel_tree_link_here -b branch_name_here


kernel/manufacturer_name_here/chipset_name_here
Eg: git clone https://github.com/LineageOS/android...mi_msm8953.git -b cm-14.1
kernel/xiaomi/msm8953

3. git clone vendor_tree_link_here vendor/manufacturer_name_here


Eg: git clone https://github.com/TheMuppets/propri...dor_xiaomi.git vendor/xiaomi

NOTE:1.To find device tree link follow the following steps:

(i)Google search "Device_name device tree github"


(ii)Select the branch and copy the device tree link.

2.To find the kernel tree link follow the below steps:
(i)Google search "lineage os github".
(ii)Input your chipset name in the search box and select the repository for your device.
(iii)Copy the link.

3.To find the vendor tree link follow the below steps:
(i)Google search "The Muppets Github".
(ii)Find the repository for your device and copy the link.

If you can't find any tree with the above methods, then simply google search that tree for your
device!!!!

6. Building the rom


1. export USE_CCACHE=1
2. prebuilts/misc/linux-x86/ccache/ccache -M 50G
3. export CCACHE_COMPRESS=1
4. . build/envsetup.sh
5. brunch device_name_here
or
5. make bacon -j8

Now it will take approx 7-8 hrs or more depending upon your internet speed.Go get a sleep till
then.

7. Uploading the ROM in Google Drive


1. cd ~
2. wget https://docs.google.com/uc?id=0B3X9G...xport=download
3. mv uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive
4. chmod +x gdrive
5. sudo install gdrive /usr/local/bin/gdrive
6. gdrive list
7. cd out/target/product
8. ls
Check your ROM name.
9. gdrive upload same_rom_name_here
Now it will show a link. Click on it and copy the code and paste it in the terminal.
Now your rom will start uploading in your Google Drive.

Congratulations You Built Your First ROM!!

CYNGAEMOD TUTORIAL

Installing Repo
Repo is a tool that makes it easier to work with Git in the context of Android.

$ mkdir ~/bin $ PATH=~/bin:$PATH

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo

Initializing a Repo client


Create an empty directory to hold your working files $ mkdir WORKING_DIRECTORY $ cd
WORKING_DIRECTORY
Run repo init to bring down the latest version of Repo with all its most recent bug fixes $ repo init -u
https://github.com/CyanogenMod/android.git -b cm-12.1

Downloading and waiting


It is time! Run command below (depending on your networking speed to initiate the long wait of
syncing!)

$ repo sync – j{Total of CPU threads}

Building the System


Initialize the environment with the envsetup.sh script $ . build/envsetup.sh

Then, you choose your specific device configuration by command $ lunch

Or simply by $ brunch <vendor_name>_<product_name>-<build_variant>

Directory tree
• build/

• bootable/

• devices/

• frameworks/

• kernel/

• out/

• packages/

• vendor/

How can I fix this AOSP build error for Oreo?


export LANG=en_US.UTF-8

rm -rf out/target/common/obj/JAVA_LIBRARIES

make -j16

USE THE CODE ABOVE AND LEARN IT.


KERNEL FACTS
I was always, wondering like what is the difference between the
Android kernel and Linux Kernel, i had I was always, wondering like
what is the difference between the Android kernel and Linux Kernel, i
had googled for it, recently i got it from one of the sites, Its extract is as
follows :googled for it , recently i got it from one of the sites, Its extract
is as follows :

‖ We checked the differences between the ‖ We checked the


differences between the Android kernel and the standard Linux kernel
and found that Google Android kernel and the standard Linux kernel
and found that Google had changed 75 files and added an additional
had changed 75 files and added an additional 88. We have prepared
an annotated list 88. We have prepared an annotated list of changed
files at t of changed files at the end he end of this document, and a of
this document, and a brief summary here. brief summary here.

Goldfish Goldfish — — 44 Files 44 Files — — The Android emulator


runs a virtual CPU that Google calls Goldfish. Goldfish The Android
emulator runs a virtual CPU that Google calls Goldfish. Goldfish
executes ARM926T instructions and has hooks for input and output
executes ARM926T instructions and has hooks for input and
output — — such as reading key presses from or such as reading key
presses from or displaying video output in the emulator. displaying
video output in the emulator.

These interfaces are implemented in files specific to the Goldfish


emulator and will not be compiled into a These interfaces are
implemented in files specific to the Goldfish emulator and will not be
compiled into a kernel that runs on real devices. So we safely ignored
these files in our work. kernel that runs on real devices. So we safely
ignored these files in our work.

YAFFS2 YAFFS2 — — 35 Files 35 Files — — Unlike PCs, which store


files on disks, mobile phones store files in sold-state flash Unlike PCs,
which store files on disks, mobile phones store files in sold-state flash
memory chips. The HTC G1 uses NAND flash, a type of flash memory
that is becoming more popular due to memory chips. The HTC G1
uses NAND flash, a type of flash memory that is becoming more
popular due to its combination of high density and low cost. its
combination of high density and low cost.

YAFFS2 is an acronym for ―Yet Another Flash File System, 2nd


edition.‖ It provides a high YAFFS2 is an acronym for ―Yet Another
Flash File System, 2nd edition.‖ It provides a high-performance -
performance interface between the Linux kernel and NAND fl interface
between the Linux kernel and NAND flash devices. YAFFS2 was
already freely available for ash devices. YAFFS2 was already freely
available for Linux. Linux. However, it is not part of However, it is not
part of the standard 2.6.25 Linux kernel, and so Google adde the
standard 2.6.25 Linux kernel, and so Google added it to d it to
Android. Android.

Bluetooth Bluetooth — — 10 files 10 files — — Google made changes


to 10 files Google made changes to 10 files in the Bluetooth
communications stack. These in the Bluetooth communications stack.
These changes fix apparent bugs related to Bluetooth headsets, and
add Bluetooth debugging and access control changes fix apparent
bugs related to Bluetooth headsets, and add Bluetooth debugging and
access control functions. functions.

Scheduler Scheduler — — 5 files 5 files — — The Android kernel also


contains slight changes to t The Android kernel also contains slight
changes to the CPU process scheduler and he CPU process
scheduler and timetime-keeping algorithms. We don‘t know the history
of these changes, and the impact was not evident based on keeping
algorithms. We don‘t know the history of these changes, and the
impact was not evident based on a cursory examination. a cursory
examination.

New Android Functionality New Android Functionality — — 28 files 28


files — — In addition to bug fix In addition to bug fixes and other small
changes, Android contains es and other small changes, Android
contains a number of new a number of new subsystems that are worth
mentioning here, including the subsystems that are worth mentioning
here, including the following: following:

IPC Binder IPC Binder — — The IPC Binder is The IPC Binder is an
Inter-Process Communication (IPC) mechanism. It allows an Inter-
Process Communication (IPC) mechanism. It allows processes to
processes to provide services to other processes via a set of higher-
level APIs than are available in standard Linux. An provide services to
other processes via a set of higher-level APIs than are available in
standard Linux. An Internet search indicated that t Internet search
indicated that the Binder concept originated at Be, Inc., and then made
its wa he Binder concept originated at Be, Inc., and then made its way
into Palm‘s y into Palm‘s software, before Google wrote a new Binder
for Android. software, before Google wrote a new Binder for Android.

Low Memory Killer Low Memory Killer — — Android adds a low-


memory killer Android adds a low-memory killer that, each time it‘s
called, scans the list of running that, each time it‘s called, scans the list
of running Linux processes, and kills one. It was not clear in our
cursory examination why Android adds a low-memory Linux
processes, and kills one. It was not clear in our cursory examination
why Android adds a low-memory killer on top of the already existing
one in the killer on top of the already existing one in the standard Linux
kernel. standard Linux kernel.

A7, Steph A7, Stephanos Towe anos Tower, Each r, Eachamukku,


amukku, Kakkanadu Kakkanadu,Kochi ,Kochi
Ashmem Ashmem — — Ashmem is an Anonymous SHared MEMory
system that adds i Ashmem is an Anonymous SHared MEMory
system that adds interfaces so processes can share nterfaces so
processes can share named blocks of memory. As an named blocks
of memory. As an example, the system could use Ashmem to
example, the system could use Ashmem to store icons, which multiple
store icons, which multiple processes could then access when drawing
their UI. The advantage of processes could then access when drawing
their UI. The advantage of Ashmem over traditional Linux Ashmem
over traditional Linux shared shared memory is that it provides a
means for the kernel to memory is that it provides a means for the
kernel to reclaim these shared memory blocks if they are not reclaim
these shared memory blocks if they are not currently in use. If a
process then tries to access a shared memory block the kernel has
freed, it will currently in use. If a process then tries to access a shared
memory block the kernel has freed, it will receive an receive an error,
and will then need to reallocate the block and reload the data. error,
and will then need to reallocate the block and reload the data.

RAM Console and Log Device RAM Console and Log Device — — To
aid in To aid in debugging, Android adds the ability to store debugging,
Android adds the ability to store kernel log messages kernel log
messages to a RAM to a RAM buffer. Additionally, Android adds a
separate logging module so buffer. Additionally, Android adds a
separate logging module so that user processes can read and that
user processes can read and write user log messages. write user log
messages.

Android Debug Bridge Android Debug Bridge — — Debugging


embedded devices can best be described as challenging. To make
Debugging embedded devices can best be described as challenging.
To make debugging easier, Google created the Android Debug Bridge
(ADB), which is debugging easier, Google created the Android Debug
Bridge (ADB), which is a protocol that runs o a protocol that runs over
a USB ver a USB link between a hardware device running Android and
a link between a hardware device running Android and a developer
writing applications on a desktop PC. developer writing applications on
a desktop PC.

Android also adds a new real-time clock, switch support, and timed
GPIO support. We list t Android also adds a new real-time clock,
switch support, and timed GPIO support. We list the impacted files he
impacted files for these new modules at the end of this document. for
these new modules at the end of this document.

Power Management Power Management — — 5 files 5


files — — Power management is one of the most difficult pieces to get
right in Power management is one of the most difficult pieces to get
right in mobile mobile devices, so we split it out into a devices, so we
split it out into a group separate from the other pieces. It‘s i group
separate from the other pieces. It‘s interesting to note that Google
added nteresting to note that Google added a new power
management system to Linux, rather a new power management
system to Linux, rather than reuse what already existed. We than
reuse what already existed. We list the impacted files at list the
impacted files at the end of this the end of this document. document.

Miscellaneous Changes Miscellaneous Changes — — 36 files 36


files — — In addition to the In addition to the above, we found a
number of above, we found a number of changes that could best
changes that could best be described as, ‗Miscellaneous.‘ Among
other things, these chang be described as, ‗Miscellaneous.‘ Among
other things, these changes include additional debugging support, es
include additional debugging support, keypad light controls, and
management of TCP networking. keypad light controls, and
management of TCP networking.

NetFilter NetFilter — — 0 files 0 files –– Finally, our change list showed


Netfilter Finally, our change list showed Netfilter as having 22 changed
files. However, as having 22 changed files. However, examination
showed the only difference was the capitalization of examination
showed the only difference was the capitalization of the filenames
(xt_DSCP.c vs. xc_dscp.c). The the filenames (xt_DSCP.c vs.
xc_dscp.c). The contents of the files were all identical. So we ignored
these files in our port
LET’S TALK LITTLE OF REPO
Installing Repo
Repo is a tool that makes it easier to work with Git in the context of
Android.IT IS HIGLY needed in compiling ROms., you download the
repo, most times you got to update the repo with bash commands
(linux).
How to access your Google Drive account from
Linux command line using Gdrive
Gdrive is basically a tool that lets you access your Google Drive
account through the command line. Yes, that means you need to
run commands for any and every Drive operation that you want
to perform. But worry not, it's not at all difficult to use and the
commands aren't difficult to remember either.
Gdrive Download, Installation, and Setup

You can easily download and install Gdrive on your Linux box by heading to the tool's
official GitHub page, and downloading the executable file for your system. For example,
I downloaded a file named gdrive-linux-386 as I work on a 32-bit Linux
distribution.

Once downloaded, make sure that the file has executable permissions. If not, grant it
the permissions through the chmod command. For example, I used the following
command:

chmod +x gdrive-linux-386

After this, you need to make sure that the tool is allowed to connect to your Google
Drive account. For this, you need to run the executable file with about argument. Here's
the command:

./gdrive-linux-386 about

You will be asked to enter a verification code, which is obtained by heading to the url
printed in the command's output and authenticating with the google account for the
drive you want access to. The following screenshots will make the process clear:

Clicking the 'Allow' button will produce the required code on the web page itself. After
the verification code is entered on the command line terminal, Gdrive will connect to
your Google Drive account. For example, here is the complete output after I entered
the code in my case:

Important note: The aforementioned authentication process will create a token file
inside a folder - named .gdrive - located in your home directory. "Note that anyone
with access to this file will also have access to your google drive," the tool's official
documentation says.
Using Gdrive

Here are examples of some of the basic Google Drive operations that you can carry out
using Gdrive. I am assuming that the Gdrive executable that you download on your
system is also named gdrive-linux-386 and is kept in your current working
directory.

List contents

To list the contents (files and directories) of your Google Drive, you can use the
following command:

./gdrive-linux-386 list

If you want to limit the maximum number of files that can be displayed in the output
(default is 30), you can add the -m flag followed a number that represents the new
maximum limit. For example:

./gdrive-linux-386 list -m 10

You can also add a query for filtering the output based on your requirement. For
example, If I only want specific files (say, that contain 'Gmail' in their name) in the
output, I can use the following command:

./gdrive-linux-386 list -m 10 --query "name contains 'gmail'"

Here's the output of the above command on my system:

Download and upload files

Given that Google Drive is a cloud storage service, so needless to say that you'll want to
use Gdrive to upload and download files to/from your Drive account. Here's how you
can do these operations:

To upload a file, run the following command:

./gdrive-linux-386 upload [file-name]


To upload a file to a specific directory, use the following command:

./gdrive-linux-386 upload --parent [dir ID] [filename]

The directory ID ([dir ID] in the command above) can be obtained from the entry of
that particular directory when you list your Drive contents using Gdrive.

To create a new directory in your Google Drive, use the following command:

./gdrive-linux-386 mkdir [directory-name]

Of course, you can create a new directory and then use its ID to upload a file to it.

Finally, you can use the following command to download a file from your Google Drive
account to your system:

./gdrive-linux-386 download [file-name]

There are several flags that help you with your download operations. For example, -f
tells Gdrive to overwrite existing file of the same name (if any), -r tells the tool to
download a directory recursively, and --delete makes sure the remote file gets deleted
when download is successful. It's worth mentioning that the last two flags also work
with upload operations.

Share files

Gdrive also lets you share your Google Drive files with others. For example, if you want
to make a file readable to everyone, you can do it through the following command:

./gdrive-linux-386 share [file ID]

Of course, that's not what we always want. Mostly, we share files with our friends or
colleagues. So, for example, if you want to share a file with someone you know, you
can do so using the following command:

./gdrive-linux-386 share [file ID] --type user --email [email add]


The above command will grant reader permission to your friend, whose email address
you have to provide in place of [email add]. If you want to grant, say, writing or
commenting permission, or even want to transfer the ownership, then you'll have to
use the --role flag. Accepted values for this flag include 'owner', 'writer', 'commenter',
and 'reader'.

Here's an example of how I used this command to share a file with one of my friends as
well as grant write permission to them.

Show file info

Gdrive also lets you access information related to any of your Google Drive files. Here's
the command for it:

./gdrive-linux-386 info [file ID]


UPLOADING FILE TO GDRIVE WITH LINUX
SSH on to your linux box and download the Linux version of gdrive from
GitHub.
cd ~
wget
https://docs.google.com/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&expo
rt=download
1
2 cd ~
wget
https://docs.google.com/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&expo
rt=download

You should see a file in your home directory called something list
uc=0B3X9GlR6EmbnWksyTEtCM0VfaFE. Rename this file to gdrive.
mv uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive
1 mv uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive

Assign this file executable rights.


chmod +x gdrive
1 chmod +x gdrive

Install the file to your usr folder.


sudo install gdrive /usr/local/bin/gdrive
1 sudo install gdrive /usr/local/bin/gdrive
You’ll need to tell Google Drive to allow this program to connect to your
account. To do this, run the gdrive program with any parameter and copy
the text it gives you to your browser. Then paste in to your SSH window
the response code that Google gives you.Run the following.
gdrive list
1 gdrive list
2016-03-18-16_44_23-olly@ollys-backup-server_-_backups_sql
YOU ARE DONE! Now you can upload files as required.
gdrive upload backups.tar.gz
1 gdrive upload backups.tar.gz

Windows
How to Build Custom Lineage OS ROM
What you'll need:-

1. A Android device with lineage OS support. See all the supported


devices here.
2. A computer running on Linux or OSX (see below for instructions on
Ubuntu installation on an virtual machine)
3. A minimum of 150 GB of disk space
4. Reliable electricity and a fast internet connection.( or a
GCP(Google Cloud Platform)
5. Patience!

Part 1:- Setting Up Ubuntu Virtual machine for Building lineage OS.

The video below will show you how to setup the virtual machine with Ubuntu running.

Whatch it directly on Youtube!

Once the installation is done and you have changed to your nearest server enter the below
commands into the terminal to update all the packages.

sudo apt-get update


sudo apt-get upgrade

Download Ubuntu Linux :- https://www.ubuntu.com/download/desktop

Download VMware Workstation Player :- http://bit.ly/1ph2jzC

Part 2:- Downloading the source code and building the Lineage OS .

Whatch it directly on Youtube!

1. Installing the SDK


•Type these commands into the terminal.
wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip -d ~

•Now open the ~/.profile file to edit it using

sudo gedit ~/.profile

•Add the following lines of code at the end of the file and then Save and Exit the file

# add Android SDK platform tools to path


if [ -d "$HOME/platform-tools" ] ; then
PATH="$HOME/platform-tools:$PATH"
fi

•Now run the command

source ~/.profile

2. Installing Necessary build Packages

•Enter these commands in a single line in your terminal to start downloading and installing all
the required packages

sudo apt-get install bc bison build-essential curl flex g++-multilib gcc-


multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline6-dev
lib32z1-dev libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev
libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush schedtool squashfs-tools
xsltproc zip zlib1g-dev openjdk-8-jdk

3. Creating the directories

•Type these commands to create three new directories


mkdir -p ~/bin
mkdir -p ~/android/system

4. Installing the repo command

•Type the commands given below to download and grant permission to repo as this tool will be
use to download all the source codes.

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo


chmod a+x ~/bin/repo

5. Put the ~/bin directory in your path of execution

•In recent versions of Ubuntu, ~/bin should already be in your PATH. You can check this by
opening ~/.profile with a text editor using

sudo gedit ~/.profile

•and by verifying that the following code exists if its missing add it if not then skip this step.

# set PATH so it includes user's private bin if it exists


if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

•if you added the above code then run this command

source ~/.profile
6. Initialize the LineageOS source repository

•Enter the following to initialize the repository

cd ~/android/system
repo init -u https://github.com/LineageOS/android.git -b cm-14.1

•If you get an error like


fatal: unable to auto-detect email address (got
lineage@ubuntu.(none)')

then run the below commands and remember to change email to your email address and user name to
your name

git config --global user.email "[email protected]"


git config --global user.name "Your Name"

•Now again run the repo init if it failed at first attempt.

repo init -u https://github.com/LineageOS/android.git -b cm-14.1

7. Download the source code

•Run this command to start the download of source code onto your computer but note that this
may take a very long time depending on your computer as you'll be downloading more than 15
GB of files.

repo sync

8. Prepare the device-specific code

•After the source has been downloaded run the following command to setup the device specific
code.

source build/envsetup.sh
breakfast bacon
Note: Breakfast bacon where bacon is the code name for the device OnePlus One and instead
of bacon you have to enter the code name of your device. Example for nexus 6P you'll enter
'breakfast angler' here angler is the code name for nexus 6P. If you don't know the code name
for your device then you can check that here.

9. Turn on caching to speed up build process

•Run this command to speed up the nightly builds.

export USE_CCACHE=1

•Now add the above line at the end of your ~/.bashrc file and save and exit the file.

sudo gedit ~/.bashrc

•Now run the below command in the terminal to limit the maximum cache size to your need else
this will fill all your disk with its cache.

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

Note: 75G at the of the commands corresponds to how many GB of space you want to for
cache if you're just building lineage OS for one device then you can allocate around 25-50 GB if
you want to build lineage os for multiple devices then target at least around 75-100GB of cache
disk space.

•You can also enable cache compression to save disk space but this will result in a slight bit of
performance slowdown it's totally up to you to enable it or ignore it.

export CCACHE_COMPRESS=1

10. Configure Jack Compiler.

•Jack is a new compiler used from lineage 14 but it always runs out of memory so to fix this run
the following command.
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -
Xmx4G"

•Also add the above line to the end of your ~/.bashrc file to configure it automatically

sudo gedit ~/.bashrc

11. Start the build.

•Now type the below commands to start building Lineage OS for your device

croot
brunch bacon

Note: Brunch bacon where bacon is the code name for the device OnePlus One and instead of
bacon you have to enter the code name of your device. Example for nexus 6P you'll enter
'brunch angler' here angler is the code name for nexus 6P. If you don't know the code name for
your device then you can check that here.

*** It will be obvious if the build has succeeded or not. If succeeded, then the
lineage OS installer package will be store in "/android/system/out/target/product/"
then inside the folder that's named based on your device. In my case the builds
are stored inside "/android/system/out/target/product/bacon/" ***

Part 3:- Fixing the most common errors.

You could face a lot of errors even if you follow the exact procedure so best advice is to
be patient and google the issue! I'm sure someone will have the solution to the issue that
you're facing. By saying that here are the solutions to few common issues that you may
face.

Whatch it directly on Youtube!


1. Proprietary blobs error.

For most of the devices you're probably going to run into this problem while running the

breakfast command.

Even if the breakfast command looks like succeeded but when you run the brunch command for
your device it will probably show you some error and say that the build failed.

All the above happens because we have to extract and get the propitiatory blobs from the device
for which you'll be building lineage OS, but there are several problems with this like may be
building an version for the device you don't have Etc...

So to overcome this this problem you can get the propitiatory blobs from
'TheMuppets' repository in GitHub https://github.com/TheMuppets.

•You can do that by typing the below command in your terminal

sudo gedit .repo/local_manifests/local_manifests.xml

•Now go to this manifests file link and copy the code from here. Then in the text editor that
opened up you have to past the copied code from the above link and then save and exit the file.
I'll just be building Lineage OS for OnePlus and Motorola devices so i have deleted all the other
lines except the lines where my maufacturer is listed and it looks something like this.

<?xml version="1.0" encoding="UTF-8"?>


<manifest>
<project name="TheMuppets/proprietary_vendor_motorola"
path="vendor/motorola"/>
<project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus"/>
</manifest>

•Finally run repo sync to sync the changes you've made.

repo sync
2.Ninja wrapper error

While building lineage OS if you have followed all the steps until here you shouldn't get this
error but sometimes it just doesn't work for no reason and may show you something like this.

Before attempting to run the below command to fix the issue and take a look at what it says i
wasn't able to recreate this error and had to fill up my storage device to get this error and it
shows there that there is no space left and only then it shows the ninja error so i can just freeup
mu sapce and the issue will be solved.

But sometimes it just shows this error with some bizarre errors and possibly the errors you
maynot know of then you can run the below command to disable Ninja Wrapper.

•Just type the below command in the terminal and the error will be fixed

export USE_NINJA=false

3.Jack Compiler Java heap size error.

Well we already discussed this above that jack runs out of memory and even though we fixed it
above there is a slight bit if chance you may get the error which many look like the these

GC overhead limit exceeded.


Try increasing heap size with java option '-Xmx<size>'.

•When you get an error like this you just have to increase the size by entering the below
command.

export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -


Xmx4G"

Notice the above command at the end which says -Xmx4G where 4G corresponds to
4GB of space that we allowed it, even after this if you get this error just try increasing
this by changing this to '-Xmx6G' or something like that.
•Also remember to change the line at the end of your ~/.bashrc file to configure it automatically

sudo gedit ~/.bashrc

Well these are most common errors that you'll face while building Lineage OS well if you face
any other issues comment down below
NOTE: The method explained here is to be followed for compiling ParanoidAndroid
v3.+
The process is WIP.(thanks to the DEV in xda that posted IT)
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!

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

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

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:

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

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

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

Code:
$ gksudo gedit /etc/udev/rules.d/51-android.rules
-> Add these lines:

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

Code:
$ 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/ja...s-1637591.html

2) Remove other JAVA Packages:

Code:
$ sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
3) Install JAVA JDK:

Code:
$ sudo mkdir -p /opt/java/64/
$ sudo cp jdk-6u##-linux-x64.bin /opt/java/64
$ sudo su -
$ cd /opt/java/64
$ chmod +x jdk-6u##-linux-x64.bin
$ ./jdk-6u##-linux-x64.bin
$ exit
REPLACE THE HASHes (#) WITH YOUR VERSION NUMBER.

-> Save & Exit

4) Add JDK PATH to .bashrc:

Code:
$ gksudo gedit ~/.bashrc
-> Add these lines:

Code:
# Java PATHs
export JAVA_HOME=/opt/java/64/jdk1.6.0_##
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)

Code:
$ 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:
Code:
$ ./configure
3) Navigate to & open Modules/Setup.
There are lines like this:

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

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

Code:
$ make
$ sudo make install
6) Add Python PATH to .bashrc:

Code:
$ gksudo gedit .bashrc
-> Add these lines:

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

Code:
$ gksudo gedit .bashrc
-> Add the following lines:
Code:
# 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:

Code:
$ gksudo gedit .profile
-> Add these lines:

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

Code:
$ android

# Install the Repo:

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

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

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.

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

Code:
$ repo sync <-parameters->
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:

Code:
$ 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 instance, if you want to run 8 fetching jobs parallelly,

Code:
$ repo sync -j8
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
Move on to Post 2.

---------------------------------------------------------------------------------
HOW TO COMPILE ANDROID ROM FROM SOURCE?
There are lots of custom Android Distributions available out there, with the popular ones being CyanogenMod, SlimROM, Paranoid Android, AOKP,
Liquid Smooth, MIUI, Xylon, Ice Cold Jelly etc.

For today’s guide, we will compile CyanogenMod 10.2, the most popular Android aftermarket ROM. The procedure is 99% same for all custom ROMs out
there, so this guide can be used as a reference to compile other ROMs too.

Pre-requisites

1. An Android Phone with readily available Kernel and Device Source, already rooted and with a custom recovery installed.
2. 64 bit Linux Distribution (We prefer Ubuntu).
3. At Least 100GB free on your Hard Disk.
4. Working knowledge of Linux Terminal Commands.
5. Reasonably fast internet connection.

Point to note: 64 bit Linux OS is a must, and it must be a native installation, not a Virtual Machine.

Set Up Your Build Machine

1. Install the Linux OS of your choice: 64 bit version, according to the official instructions. (The guide will assume that we are running Ubuntu 13.04).
Keep a partition of at least 100GB with 16GB Swap Partition.

2. Install the following list of packages: Open Terminal app, and type

sudo apt-get install <package -name>

press enter and it will prompt you for your password.

Package List

1. git-core
2. gnupg
3. flex
4. bison
5. python
6. rar
7. original-awk
8. gawk
9. p7zip-full
10. gperf
11. libsdl1.2-dev
12. libesd0-dev
13. libwxgtk2.6-dev
14. squashfs-tools
15. build-essential
16. zip
17. curl
18. libncurses5-dev
19. zlib1g-dev
20. pngcrush
21. schedtool
22. libc6-dev
23. x11proto-core-dev
24. libx11-dev
25. libg11-mesa-dev
26. mingw32
27. tofrodos
28. python-markdown
29. libxml2-utils
30. g++-multilib
31. lib32z1-dev
32. ia32-libs
33. lib32ncurses5-dev
34. lib32readline-gplv2-dev
35. gcc-multilib
36. g++-multilib
37. xsltproc

3. Install Java JDK 1.6 for Linux 64-bit: File name should be jdk-6u##-linux-x64.bin, ## are version numbers. Move the downloaded package to your
home directory. Open Terminal app and run the following set of commands:

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


2. sudo mkdir –p /opt/java/64/
3. sudo cp jdk-6u##-linux-x64.bin /opt/java/64
4. sudo su –
5. cd /opt/java/64
6. chmod a+x jdk-6u##-linux-x64.bin
7. ./jdk-6u##-linux-x64.bin
8. exit

Now, we must add JDK Path to .bashrc

1. sudo gedit ~/.bashrc

Add these lines in the ending of the text file

1. # Java Path
2. export JAVA_HOME=/opt/java/64/jdk1.6.0_##
3. export PATH=$PATH:$JAVA_HOME/bin

4. Install Android SDK: Open Terminal App

1. cd ~
2. mkdir android && cd android
3. mkdir sdk

Download Android SDK from http://developer.android.com/sdk/index.html. Extract the package contents to ~/android/sdk We must add Android SDK
path to .bashrc

1. sudo gedit ~/.bashrc

Add these lines to the ending of the text file:

1. # Android SDK Path


2. export PATH=$PATH:~/android/sdk
3. export PATH=$PATH:~/android/sdk/platform-tools
4. export PATH=$PATH:~/android/sdk/tools

Now, install Android SDK Tools by typing

1. android

5. Set up your github account and remote repo: You can skip this step if CyanogenMod supports your phone officially. Go to github.com, and make an
account for yourself. For this guide, I am considering your username as ‘user’.

Visit ‘github.com/CyanogenMod/android’, press Fork. The remote manifest will be forked, and available in your personal repo.

Now, go to ‘github.com/user/android’. Open the file default.xml, press Edit. Find this line:

1. <project path="android" name="CyanogenMod/android" />

And replace this with

1. <project path=”android” name="user/android" />

I am considering your device’s kernel source, device source and vendor libs for Android 4.3 to be at

1. github.com/user2/kernel_source
2. github.com/user2/device_source
3. github.com/user2/device-common_source
4. github.com/user2/vendor

I am assuming the branch to be named ‘jb4.3’. You can find the exact name in the actual repo. Then, at the end of the file, add these lines, modifying them
according to your device’s source code.

1. <project path="kernel/your_company/your_device" name="user2/kernel_source" remote="github"


revision="jb4.3" />
2. <project path="device/your_company/your_device" name="user2/device_source" remote="github"
revision="jb4.3" />
3. <project path="device/your_company/your_device-common" name="user2/device-common_source"
remote="github" revision="jb4.3" />
4. <project path="vendor/your_company" name="user2/vendor" remote="github" revision="jb4.3" />

Commit your changes. Your remote manifest is ready to be deployed.

6. Install Repo Command: Open Terminal and type

1. cd ~
2. mkdir ~/bin
3. curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
4. chmod a+x ~/bin/repo

We must add Repo path to .bashrc

1. sudo gedit ~/.bashrc

Add this line to the end of the text file


1. export PATH=$PATH:~/bin

7. Fetch the ROM source code: Open Terminal and type

1. mkdir ~/android/cm
2. cd ~/android/cm

If you needed Step 5 , then type

1. repo init –u git://github.com/user/android.git –b cm-10.2

If your device supports CyanogenMod 10.2 officially, then type

1. repo init –u git://github.com/CyanogenMod/android.git –b cm-10.2

Now run

1. repo sync –j16

Go grab a coffee, or a meal, it’s gonna take a long time. The source code is well over 10GB in size, so it will take quite some time.

8. Set up the Device Specific Stuff: If your device supports CyanogenMod 10.2 officially, then open Terminal and type

1. cd ~/android/cm
2. . build/envsetup.sh && breakfast <device_codename>

It will take some time, the device source is about 3GB in size. Then, you need to have official CM10.2 installed on your phone, connect it to your PC in
USB Debugging mode, and run the following commands:

1. adb root
2. cd ~/android/cm/device/<your_company>/<your_device>/
3. ./extract-files.sh

If your device does not support CyanogenMod 10.2 officially, then you got nothing to do in this step, the sources are already waiting for you.

9. Download Prebuilt Stuff and set up Toolchain: Open Terminal and type

1. cd ~/android/cm/vendor/cm
2. sh ./get-prebuilts

Now, we must add the Toolchain PATH to ./bashrc

1. cd ~/android/cm
2. sudo gedit ~/.bashrc

Add these lines to the end of the text file

1. # Android Toolchain
2. export ARCH=arm
3. export CCOMPILE=$CROSS_COMPILE
4. export CROSS_COMPILE=arm-eabi-
5. export PATH=$PATH:~/android/cm/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
10. Build your ROM: So, everything is all right and ready. It’s time to build the ROM. Open Terminal and type

1. cd ~/android/cm
2. . build/envsetup.sh
3. brunch <device_codename>

Time to go take a nap. It will take a zillion years to build the ROM on an average computer. Well, that was exaggeration, but on my home PC (Core i5 2nd
gen with 8GB RAM), it takes over 3 hours to build from scratch. Hopefully, there will be no errors, and the build will complete fine. You will get the
output package in

1. ~/android/cm/out/target/product/<your_device>/cm-10.2-something-UNOFFICIAL-<your_device>.zip

It’s time to install your newly compiled ROM on your phone. Download Google Apps package from “www.goo.im/gapps” for the appropriate Android
version. Put both those packages in your phone, and flash them in recovery mode. Voila, your own compiled ROM is now running your device.

Well, so you learnt how to compile a ROM. So, now what?

Update Your Source ROM

To fetch new source code updates to your locally downloaded source code, open Terminal and type

1. cd ~/android/cm
2. repo sync –j16

To build your ROM, after updating source code, open terminal and type

1. cd ~/android/cm
2. make installclean
3. find ./out/ -name ‘build.prop’ | xargs rm
4. find ./out/ -name ‘cm_<your_device>-target_files-eng.*.zip’ | xargs rm
5. . build/envsetup.sh
6. brunch <your_device>

Since you are not re-building from scratch, but re-building as it is, it will take significantly less time, only about 15-30 mins in most cases. You should sync
your local source every week or so, to keep your local source fresh.

Clean Your Working Directory

To clean your working directory completely (read: return your source folder to stock condition), open Terminal and type the following commands.

1. cd ~/android/cm
2. make installclean
3. make clobber

Bear in mind, that after running these commands, all your output data will be removed, so the next build will take 3-4 hours again, as everything is re-built
from scratch. If your Hard Disk partition is small, say around 100GB, you should clean your working directory about once every 4 builds, or else, you will
run out of Hard Disk space.

Speed up your build by CCACHE

Building a ROM takes a lot of time. But the time can be cut down by about 30-45% by using CCACHE. CCACHE stands for compiler cache, it caches the
compilation output from your earlier builds, so that it can be re-used in later builds.
Note that CCACHE needs a lot of space on your Hard Disk for caching the content, so its recommended if and only if your Hard Disk partition is
somewhere in the vicinity of 200GB or higher. To set up CCACHE, open Terminal and type:

1. cd ~/android/cm
2. export USE_CCACHE=1
3. export CACHE_DIR=~/.ccache
4. prebuilts/misc/linux-x86/ccache/ccache –M 50G

You can change the maximum size allocation to CCACHE from 50GB to whatever you want, but a minimum of around 30GB should be used for good
results.

Fetch Commits from Other ROMs

You can cherry-pick features from other ROMs source code. Say for example, I want to pick Feature A , with commit ID “12345” from repository
“github.com/user/reporepo”.

You navigate to the package in your local source code and run these in Terminal.

1. cd ~/<path_to_reporepo_packages>
2. git fetch https://github.com/user/reporepo
3. git cherry-pick 12345
CREDITS
1. MICHAEL(SMHOS.ORG) IN XDA
AND MY TEAM SPEEDEVS TEAMS
PLS DONATE TO ME 
BITCOIN ADDRESS (VERY IMPORTANT)
12E4FPWQQYAN6V9YWK6HTN6PC1TXYZBNEP
2. @AKHILNARAG (Resurrection Remix with ACAR in telegram)
3. ALL THE DEVS IN XDA ,MIUI FORUM AND GOOGLE PLUS
FOR THEIR HELP

PLS VISIT MY BLOG BELOW

WEBSITE
HTTP://SPEEDDEVS.BLOGSPOT.COM OR http://SPEEDEVS.CF

IF YOU HAVE COMPLAINS OR A WAY TO IMPROVE ON THIS SITE CONTACT ME ON +2347053028992 OR


ON TELEGRAM WITH THE NUMBER ABOVE.
THANKS TO YOU ALL READIG THIS GUIDE GOD BLESS YOU ;
YOU CANA LSO VISIT MY CHURCH WEBSITE @ HTTP://WWW.SMHOS.ORG
(NOTE: I DON’T OWN THIS SITE: smhos.org) LOL
I
The SPEEDEVS team is created to be the
best in Computer Development all round
we are here in bringing the best in every
developer to BE a creator and inventor.

THIS IS AN UPDATED GUIDE 1.1

You might also like