[GUIDE][COMPLETE] Android ROM Development From Source To End

Search This thread

NepoRood

Recognized Contributor / Retired Forum Moderator
Jan 26, 2016
2,990
3,985
Bugtussle
Thank you very much for the tip. I still couldn't get it to bake the app the at least now I'm looking in the right place. I'll get back to googling maybe I find a few examples to inspire from. Either way, a big thank you for putting me on the right track.
No worries, all you really need in your Android.mk is the first line:
LOCAL_PATH := $(call my-dir)

Then, you want to add your package to the lineage common.mk file, located here:
vendor/lineage/config/common.mk

If you look through the file, I'm sure you'll find a good place to add
 
  • Like
Reactions: Blue_Monk

moj.enjoy

Member
Nov 6, 2014
35
11
hello i want to build havoc os 11 for canro (mi4). i synced source codes with "repo sync -j1" or "repo sync -j4"...
after brunch command. i saw this error...i think that i shoud sync some other repo but i dont know exactly ... pls help me . thnaks alot.
100% 2/2] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/
build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: hardware/havoc/interfaces/cryptfshw/1.0/Android.bp:15:1: "[email protected]" depen
ds on undefined module "[email protected]"
error: frameworks/base/packages/SettingsLib/Android.bp:1:1: "SettingsLib" depends on undefined module "VendorS
upport-preference"
error: hardware/havoc/interfaces/cryptfshw/1.0/qsee/Android.bp:15:1: "[email protected]
e-qti.qsee" depends on undefined module "[email protected]"
error: packages/apps/TouchGestures/Android.bp:1:1: "TouchGestures" depends on undefined module "VendorSupport-
preference"
error: packages/apps/CustomDoze/Android.bp:1:1: "CustomDoze" depends on undefined module "VendorSupport-prefer
ence"
error: packages/apps/Settings/Android.bp:22:1: "Settings-core" depends on undefined module "VendorSupport-pref
erence"
error: hardware/qcom-caf/sm8350/display/composer/Android.bp:3:1: "vendor.qti.hardware.display.composer-service
" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:113:1: "[email protected]
ti-display" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:113:1: "[email protected]
ti-display" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:113:1: "[email protected]
ti-display" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:113:1: "[email protected]
ti-display" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:77:1: "[email protected]
i-display" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:77:1: "[email protected]
i-display" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:77:1: "[email protected]
i-display" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:152:1: "vendor.qti.hardware.display.allocator-servi
ce" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:152:1: "vendor.qti.hardware.display.allocator-servi
ce" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:152:1: "vendor.qti.hardware.display.allocator-servi
ce" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:152:1: "vendor.qti.hardware.display.allocator-servi
ce" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:152:1: "vendor.qti.hardware.display.allocator-servi
ce" depends on undefined module "[email protected]"
error: hardware/qcom-caf/sm8350/display/gralloc/Android.bp:152:1: "vendor.qti.hardware.display.allocator-servi
ce" depends on undefined module "[email protected]"
22:12:47 soong bootstrap failed with: exit status 1

#### failed to build some targets (13 seconds) ####
 

rdanielk

New member
Dec 15, 2021
4
1
hello all, I am trying to add apks to my system/app folder in the SYSTEM.PARTITION

is there a specific way to do that? or anyone could point me to guide with step by step process?

I tried to add two apks in there. FX File Explorer and Youtube.

I can repack the rom and flash to the device, The two apps seems to be installed, but only the FX File Explorer works.
The Youtube apps open a black screen, and goes back to main screen, if I try to open it.

Also, I would like to try to port my rom to android tv, if there is anyone here that would be willing to help in exchange of financial help, please send me a PM.

Any help would be much appreciated.
 

DiamondJohn

Recognized Contributor
Aug 31, 2013
6,483
6,456
Sydney
hello all, I am trying to add apks to my system/app folder in the SYSTEM.PARTITION

is there a specific way to do that? or anyone could point me to guide with step by step process?

I tried to add two apks in there. FX File Explorer and Youtube.

I can repack the rom and flash to the device, The two apps seems to be installed, but only the FX File Explorer works.
The Youtube apps open a black screen, and goes back to main screen, if I try to open it.

Also, I would like to try to port my rom to android tv, if there is anyone here that would be willing to help in exchange of financial help, please send me a PM.

Any help would be much appreciated.
Thee are two different cases here, and you seemed to have gotten the FX File explorer correct. However, I think the latest YouTube releases will not be the exact same, as its a multi-part APK. And isnt YouTube installed as a part of GApps? If not, i would check other GitHub RPOM repositories to see how they did it. Sorry I cant be more helpful.

Now from my opinion / point of view. A few years back I used to build & dist ROMs. I replaced a few of the default apps in the custom ROMs with improved APK's. After a while I reaslised the negatives of doing such. Whenever you add an app to the ROM, chances are that it will be updated, and possibly by the time the ROM actually gets first installed. Therefore, the APK I had installed on the system partition, will be replaced by the update which gets installed to the data partition, leaving the APK on the system partition. If the app is not taking any advantages of being installed as a system app, then its a waste. The only benefit would be to others in that they get my personal recommendation of a specific app or dont need to think about what they should install as a minimum.

On another opinion, I would look into MiX by @HootanParsa, distributed here on XDA, as a file explorer ovcer FX Explorer. A few years back I checked with him and he gave the ok for me to include it in my ROMs.
 

rdanielk

New member
Dec 15, 2021
4
1
Thee are two different cases here, and you seemed to have gotten the FX File explorer correct. However, I think the latest YouTube releases will not be the exact same, as its a multi-part APK. And isnt YouTube installed as a part of GApps? If not, i would check other GitHub RPOM repositories to see how they did it. Sorry I cant be more helpful.

Now from my opinion / point of view. A few years back I used to build & dist ROMs. I replaced a few of the default apps in the custom ROMs with improved APK's. After a while I reaslised the negatives of doing such. Whenever you add an app to the ROM, chances are that it will be updated, and possibly by the time the ROM actually gets first installed. Therefore, the APK I had installed on the system partition, will be replaced by the update which gets installed to the data partition, leaving the APK on the system partition. If the app is not taking any advantages of being installed as a system app, then its a waste. The only benefit would be to others in that they get my personal recommendation of a specific app or dont need to think about what they should install as a minimum.

On another opinion, I would look into MiX by @HootanParsa, distributed here on XDA, as a file explorer ovcer FX Explorer. A few years back I checked with him and he gave the ok for me to include it in my ROMs.
Thank you for the explanation... I actually downloaded the Youtube Apk from apkmirror... If I install that same apk after flashing with the app installer, all works fine, I just cannot understand why if I put into the system/app folder it won't install properly.

I was thinking that was something regarding to other files in the rom, maybe a script or something like it...

Thanks again
 

DiamondJohn

Recognized Contributor
Aug 31, 2013
6,483
6,456
Sydney
Thank you for the explanation... I actually downloaded the Youtube Apk from apkmirror... If I install that same apk after flashing with the app installer, all works fine, I just cannot understand why if I put into the system/app folder it won't install properly.

I was thinking that was something regarding to other files in the rom, maybe a script or something like it...

Thanks again
Try installing the APK to your device, and check what files ares being created. Maybe the YT APK must be ODEXed to run. IDK.

One idea I would try, is to convert your /data/app YT files to a magisk module, which would then appear as being on your system partition on the next boot.
 

Zentriks

Member
Dec 26, 2021
13
2
Xiaomi Mi 8
Hey guys, I need some help with building ROM for S5 Mini. As of right now I'm trying to build LineageOS 16 to get to know it. I followed your guide and even looked at other guides. My problem is even if I apply

Code:
git clone https://github.com/LineageOS/android_hardware_samsung -b lineage-16.0 hardware/android_hardware_samsung

I get this error

Code:
[email protected]:/home/marcus/android/lineageos16# make clean-apache-xml
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=9
LINEAGE_VERSION=16.0-20220811-UNOFFICIAL-kminilte
TARGET_PRODUCT=lineage_kminilte
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a7
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.18.16-zen1-1-zen-x86_64-Ubuntu-22.04.1-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=PQ3A.190801.002
OUT_DIR=/home/marcus/android/lineageos16/out
============================================
[1/1] /home/marcus/android/lineageos16/out/soong/.min.../android/lineageos16/out/soong/.bootstrap/build.ninja
[61/62] glob prebuilts/ndk/stl.bp
[80/80] /home/marcus/android/lineageos16/out/soong/.b...home/marcus/android/lineageos16/out/soong/build.ninja
/home/marcus/android/lineageos16/out/build-lineage_kminilte-cleanspec.ninja is missing, regenerating...
/home/marcus/android/lineageos16/out/build-lineage_kminilte.ninja is missing, regenerating...
[113/1035] including device/samsung/kminilte/Android.mk ...
YD>>LOCAL_MODULE=sensors.universal3470, LOCAL_SRC_FILES=sensors.cpp HeartRateSensor.cpp LightSensor.cpp Proxim
itySensor.cpp, LOCAL_SHARED_LIBRARIES=libinvensense_hal libcutils libutils libdl liblog libmllite libhardware_
legacy
[265/1035] including frameworks/av/camera/Android.mk ...
frameworks/av/camera/cameraserver/Android.mk:18: warning: Target has integrated cameraserver into mediaserver.
This is weakening security measures introduced in 7.0
[1035/1035] including vendor/qcom/opensource/dataservices/Android.mk ...
hardware/ril/reference-ril/Android.mk: error: "libreference-ril (SHARED_LIBRARIES android-arm) missing libril 
(SHARED_LIBRARIES android-arm)"
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer rea
l problems until later in the build.
hardware/ril/rild/Android.mk: error: "rild (EXECUTABLES android-arm) missing libril (SHARED_LIBRARIES android-
arm)"
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer rea
l problems until later in the build.
build/make/core/main.mk:844: error: exiting from previous errors.
14:31:27 ckati failed with: exit status 1

#### failed to build some targets (30 seconds) ####

I'm using Ubuntu 22.04 via Distrobox. Thanks for your help in advance!
 
Last edited:

NepoRood

Recognized Contributor / Retired Forum Moderator
Jan 26, 2016
2,990
3,985
Bugtussle
Hey guys, I need some help with building ROM for S5 Mini. As of right now I'm trying to build LineageOS 16 to get to know it. I followed your guide and even looked at other guides. My problem is even if I apply

Code:
git clone https://github.com/LineageOS/android_hardware_samsung -b lineage-16.0 hardware/android_hardware_samsung
For one, change your clone line to this:

Code:
git clone https://github.com/LineageOS/android_hardware_samsung -b lineage-16.0 hardware/samsung

Repos rarely have an underscore "_" in the name, some do, but not the one for Samsung hardware
 

NepoRood

Recognized Contributor / Retired Forum Moderator
Jan 26, 2016
2,990
3,985
Bugtussle
hey am pretty new to this, just wanted to ask, can a linux server [SSH] be used [its provided by my college] ?

sorry for the retarded question ;_;
Sure, as long as it has the needed hardware requirements. Depending on Android version, you'll need around 150-200Gb of free space, at least 16Gb RAM (the more the better on this one, although, I know people that build with half that) and a lot of patience...
 
  • Like
Reactions: KD6-3.7
Jan 10, 2022
40
10
Google Pixel 3 XL
Hi everyone. So I currently have a Motorola Edge + (Burton) that is currently running Android 12 and I want to update it to Android 13 (Was gonna try LineageOS, but that seemed more complicated since there is no version for my device).
However, my device will no longer receive updates to newer versions of Android and therefore I have decided to try and build it myself.

Now I have already done a bunch of research and learned alot of what I need to do, but I do have a few questions.

1) When I am building my project, do I need to get the device tree and kernel source from Motorola's Github? Or can I extract it from the stock firmware? The reason I ask is because on Github it is S1PB32.41-10-17 where as on my phone and the stock firmware that I have downloaded it is S1PB32.41-10-19-2.

2) If I don't need to pull the files from Github and can use the stockfirmware that I have backed up, what commands do I need to enter during the build process (I'm new to Linux commands) to get these files I have?

3) Now this question I believe only needs to be answered if I have to use Github, but when I have the proprietary device blobs (Using CRB Android Kitchen), will there be a conflict when building (because the kernel/device tree is a different version)

I apologize if I may have misunderstood some things, but I basing my knowledge on various tutorials I have found.

Also, I apologize if this question has already been answered in this thread, I just couldn't find it yet.

Finally thank you to Diamondjohn for their help and referring me here.
 

NepoRood

Recognized Contributor / Retired Forum Moderator
Jan 26, 2016
2,990
3,985
Bugtussle
Hi everyone. So I currently have a Motorola Edge + (Burton) that is currently running Android 12 and I want to update it to Android 13 (Was gonna try LineageOS, but that seemed more complicated since there is no version for my device).
However, my device will no longer receive updates to newer versions of Android and therefore I have decided to try and build it myself.

Now I have already done a bunch of research and learned alot of what I need to do, but I do have a few questions.

1) When I am building my project, do I need to get the device tree and kernel source from Motorola's Github? Or can I extract it from the stock firmware? The reason I ask is because on Github it is S1PB32.41-10-17 where as on my phone and the stock firmware that I have downloaded it is S1PB32.41-10-19-2.

2) If I don't need to pull the files from Github and can use the stockfirmware that I have backed up, what commands do I need to enter during the build process (I'm new to Linux commands) to get these files I have?

3) Now this question I believe only needs to be answered if I have to use Github, but when I have the proprietary device blobs (Using CRB Android Kitchen), will there be a conflict when building (because the kernel/device tree is a different version)

I apologize if I may have misunderstood some things, but I basing my knowledge on various tutorials I have found.

Also, I apologize if this question has already been answered in this thread, I just couldn't find it yet.

Finally thank you to Diamondjohn for their help and referring me here.

I've answered in the same order you asked:

1) Yes, you will need a device tree for certain, if there's one on GitHub for your device, start with it. You cannot extract a device tree from your firmware, AFAIK anyway.

2) IF you're talking about extracting specific files from the device, for example to create a vendor tree, then yes, there are several ways to extract from stock firmware.

3) It is highly likely you will encounter conflicts. Not only are you new to Linux, you're adding in building AOSP for the first time, possibly bringing up a device, vendor and having a build-able and bootable kernel...

There's a lot to building your own firmware (ROM), even more so for devices that haven't been brought to custom before. I'm not saying you can't do it, I'm saying it's a process, lol


My advice:
* Try and build Lineage, they accommodate the most devices and have the largest knowledge base
* I also advise to not go straight for Android 13, try 12.1 (lineage-19.1) first, since that is what the device is currently running
* Depending on your device (I didn't do much research), look at similar devices that have the same SoC, display size, hardware, etc


I did happen across an Unofficial TWRP, you decide what to do with that. Probably be helpful if it works right.

Feel free to post again if you have any more questions.


Best of Luck,
Nepo
 
Jan 10, 2022
40
10
Google Pixel 3 XL
I've answered in the same order you asked:

1) Yes, you will need a device tree for certain, if there's one on GitHub for your device, start with it. You cannot extract a device tree from your firmware, AFAIK anyway.

2) IF you're talking about extracting specific files from the device, for example to create a vendor tree, then yes, there are several ways to extract from stock firmware.

3) It is highly likely you will encounter conflicts. Not only are you new to Linux, you're adding in building AOSP for the first time, possibly bringing up a device, vendor and having a build-able and bootable kernel...

There's a lot to building your own firmware (ROM), even more so for devices that haven't been brought to custom before. I'm not saying you can't do it, I'm saying it's a process, lol


My advice:
* Try and build Lineage, they accommodate the most devices and have the largest knowledge base
* I also advise to not go straight for Android 13, try 12.1 (lineage-19.1) first, since that is what the device is currently running
* Depending on your device (I didn't do much research), look at similar devices that have the same SoC, display size, hardware, etc


I did happen across an Unofficial TWRP, you decide what to do with that. Probably be helpful if it works right.

Feel free to post again if you have any more questions.


Best of Luck,
Nepo
Hey there, thanks for your reply, I am definitely going to take your suggestions to heart. But first I do have a few more questions.

1)I found a guide on how to compile a kernel from source and then on how to add it to your stock rom. By following this guide, can I use it to update my devices kernel to the newer version on Github? I'm just talking about updating my current rom to a slightly newer kernel, not the Android version itself or to a custom rom.

2)If I'm successful in updating the firmware in my current stock rom, is there still alot to it to port my device to LineageOS 19.1? Even if I have access to all the device files?

3)If I do attempt to build Lineage, do the device tree, kernel and proprietary blobs need to be on Github, or can I build Lineage with them on my computer? This will be a major factor for me, as I am not 100% if any or all of proprietary device blobs are on Motorola's Github, and the only way I know to get these for sure is with CRB Android Kitchen.

Based on my research and your advice, I'm thinking I may be in over my head. I'm probably going to still follow some of the guides I have found and see what I can accomplish.

Brad
 
  • Like
Reactions: NepoRood

NepoRood

Recognized Contributor / Retired Forum Moderator
Jan 26, 2016
2,990
3,985
Bugtussle
Hey there, thanks for your reply, I am definitely going to take your suggestions to heart. But first I do have a few more questions.

1)I found a guide on how to compile a kernel from source and then on how to add it to your stock rom. By following this guide, can I use it to update my devices kernel to the newer version on Github? I'm just talking about updating my current rom to a slightly newer kernel, not the Android version itself or to a custom rom.

2)If I'm successful in updating the firmware in my current stock rom, is there still alot to it to port my device to LineageOS 19.1? Even if I have access to all the device files?

3)If I do attempt to build Lineage, do the device tree, kernel and proprietary blobs need to be on Github, or can I build Lineage with them on my computer? This will be a major factor for me, as I am not 100% if any or all of proprietary device blobs are on Motorola's Github, and the only way I know to get these for sure is with CRB Android Kitchen.

Based on my research and your advice, I'm thinking I may be in over my head. I'm probably going to still follow some of the guides I have found and see what I can accomplish.

Brad
Same deal:

1) You can certainly try, I am not familiar with your device and therefore really can't say, but I'm sure its "possible"
2) You're not going to be building a "stock" firmware update, your only option for building is a custom variation of AOSP (ie, LineageOS)
3) No, you are not "required" to push anything to an online git service, it is highly recommended though.
3.1) Lineage has some handy scripts and tools for extracting files from factory firmware.

Building a custom ROM not only requires a lot of patience, it also requires determination. You keep bringing up that kitchen (CRB) have you tried modifying your factory firmware in any way?

Kitchens can be a fun learning experience and there are several available, just want to make sure that the developer hasn't retired or something, lol.

Personally, I use the Pro version of SuperR Kitchen (Linux)

Regards,
Nepo
 
Jan 10, 2022
40
10
Google Pixel 3 XL
Same deal:

1) You can certainly try, I am not familiar with your device and therefore really can't say, but I'm sure its "possible"
2) You're not going to be building a "stock" firmware update, your only option for building is a custom variation of AOSP (ie, LineageOS)
3) No, you are not "required" to push anything to an online git service, it is highly recommended though.
3.1) Lineage has some handy scripts and tools for extracting files from factory firmware.

Building a custom ROM not only requires a lot of patience, it also requires determination. You keep bringing up that kitchen (CRB) have you tried modifying your factory firmware in any way?

Kitchens can be a fun learning experience and there are several available, just want to make sure that the developer hasn't retired or something, lol.

Personally, I use the Pro version of SuperR Kitchen (Linux)

Regards,
Nepo

I haven't actually used CRB yet, but it looked like it would probably be a good program and it looked like it has a user friendly interface. Also, I'm pretty sure it is still being maintained. I plan to use it soon to attempt to merge the updated kernel for my device with my stock rom.

I appreciate all the advice you have given me, and I think I am going to take it slow.

Starting to get a headache from all the info required lol.

Brad
 
  • Like
Reactions: NepoRood

Top Liked Posts

  • There are no posts matching your filters.
  • 448
    Hello Everyone....:D:D

    Today I will present you all the ultimate guide for ROM development starting from Source to End.
    This guide will be applicable to all devices.
    So lets Start :D



    What is Android? :rolleyes:

    Android is the open-source operating system used for smartphones. Full Freedom for people using it :D


    What is Android Source Code?

    Android is an open-source software stack created for a wide array of devices with different form factors. The primary purposes of Android are to create an open software platform available for carriers, OEMs, and developers to make their innovative ideas a reality and to introduce a successful, real-world product that improves the mobile experience for users.The result is a full, production-quality consumer product with source code open for customization and porting.
    So basically Android Allows to customize the things you like and make new things without any Restrictions. Cool isn’t it? :cool:

    What is Android ROM ?
    The Android ROM is the Android operating system. This is the User interface (Sense UI in HTC phones) and the file system for maintaining contacts etc. It is composed of a Linux kernel and various add-ons to achieve specific functionality.

    What does a Android Rom Contain ?
    Basically a Android Rom Contains following main things :
    · Kernel
    · Bootloader
    · Recovery
    · Radio
    · Framework
    · Apps
    · core
    · android-runtime,Etc


    Some Basics About Above Terms

    Kernel :
    A kernel is critical component of the Android and all operating systems. It can be seen as a sort of bridge between the applications and the actual hardware of a device. Android devices use the Linux kernel, but it's not the exact same kernel other Linux-based operating systems use. There's a lot of Android specific code built in, and Google's Android kernel maintainers have their work cut out for them. OEMs have to contribute as well, because they need to develop hardware drivers for the parts they're using for the kernel version they're using. This is why it takes a while for independent Android developers and hackers to port new versions to older devices and get everything working. Drivers written to work with the Gingerbread kernel on a phone won't necessarily work with the Ice Cream Sandwich kernel. And that's important, because one of the kernel's main functions is to control the hardware. It's a whole lot of source code, with more options while building it than you can imagine, but in the end it's just the intermediary between the hardware and the software. So basically if any instruction is given to mobile it first gives the command to kernel for the particular task execution.

    Bootloader :

    The bootloader is code that is executed before any Operating System starts to run. Bootloaders basically package the instructions to boot operating system kernel and most of them also have their own debugging or modification environment. Think of the bootloader as a security checkpoint for all those partitions. Because if you’re able to swap out what’s on those partitions, you’re able to break things if you don’t know what you’re doing. So basically it commands the kernel of your device to Boot the Device properly without any issues. So careful with bootloader since it can mess things very badly.

    Recovery :

    [FONT=&quot]Recovery is defined in simple terms as a source of backup. Whenever your phone firmware is corrupted, the recovery does the job in helping you to restore or repair your faulty or buggy firmware into working condition. It is also used for flashing the Rom’s , kernel and many more things.

    [/FONT]
    Radio[FONT=&quot]
    [/FONT]

    The lowest part of software layer is the radio: this is the very first thing that runs, just before the bootloader. It control all wireless communication like GSM Antenna, GPS etc.


    These are main parts of Android Operating System.

    [FONT=&quot]Now has we know what is Android and What it contains lets move to the Next major step. That is Android Rom Development from Source. But before starting this we need some Initial Setup and development Enviroment .[/FONT]

    Android Rom Development

    Setting Up Linux Enviroment




    Pre – Requirements for Android Rom Development.
    1) Linux Operating System ( I will take Ubuntu 13.10 has Example and also recommend you all)
    2) Java Development Kit (JDK)
    3) Some Tools.

    Once you Download Ubuntu 13.10 you can Install it in 2 ways :
    1) Installing has primary OS
    2) Installing Inside the Windows ( Using VM or VB)
    3) Dual booting Linux alongside Windows. ( Using different Partitions )


    Here I will explain how to Install Linux inside Windows. You can use VirtualBox (Free) or VM Workstation/Player (Paid) Softwares. In this guide I will take example of Virtual Box.

    Pre-requirements

    1) Windows 7 64 bit
    2) Download Virtual Box.
    3) Install the VirtualBox
    4) See that JDK is installed before installing VirtualBox
    5) Ubuntu 13.10 ISO file ( Download it)

    Installing Ubuntu 13.10 In VirtualBox
    I will be using 2 words.
    Guest : Operating System in Virtual Box 64 bit
    Host : Windows 7 .


    Note : Since we need to Install Ubuntu 64bit version Intel VT-x should be enabled else you will not be able to install 64bit. Your processor should support that feature.
    Enabling VT-x.
    1) ShutDown PC.
    2) Boot into SetUp Menu (Bios Settings)
    3) Go to Advanced --> Advanced Processor Options --> Intel(R) Virtualization Technology.
    4) Enable it.
    5) Save the settings.
    6) Reboot

    Installation of Ubuntu 13.10 64bit


    1) Open VirtualBox.

    2) Click on New button



    M3QKn8t.png


    ·3) [FONT=&quot]Type the Name you want to give to this OS which will displayed everytime you open VirtualBox.

    qw7keQx.png


    b6ACrTD.png


    [/FONT] 4) Now you have to set the amount of RAM you want to allocate for your Guest OS. Now this is tricky and Dangerous part. Hey don’t worry !! Its simple :D I will explain this with a simple Example : Think that your PC has 10GB of RAM installed and you have Windows 7 64bit OS (Which u need off course :p ) Now out of 10GB of RAM 4Gb will be needed for your Host to work smoothly. The remaining 6GB can be allotted to work for Virtual Box Guest OS. Now you may have a question in your mind why so much RAM is needed while VB can run in 1 GB too?
    The Answer for this simple that has the RAM for Guest Increases your ROM compiling/building speed too increases drastically. That is the reason RAM is needed a bit more here.
    Now In VirtualBox you can see that green dotted line ending with red dotted line showing how much RAM you are allocating NEVER EVER CROSS GREEN LINE TO RED DOING SO CAN CRASH YOUR PC HAS IT IS THE SAME LIMIT FOR THE WINDOWS TO WORK. SO CAREFULL. It is the Max Amount of Ram you can allocate to VB. But always keep pointer 2 dotes below the RED to Be on safer side. After setting click Next.

    FRx9MXi.png


    5) Now here you have to create virtual drive for you Linux OS and its Files. It’s same has Hard Disk for your Windows PC.Were Linux is installed and RUN.Now click on Create New Virtual Hard Drive Now and click Create button.
    · You will get various formats of Virtual Drives. Always select VMDK Since it is supported by other Softwares like VM Workstation (Paid) . Click Next.


    ED0PEO1.png


    jLe0HkX.png


    · 6) Now you will get a option to select Dynamically Allocated or Fixed Size. Select Dynamically Allocated and don’t tick Split into files option has it will mess everything.


    EtrNQrT.png


    7) Enter the Amount of HDD Space you want to allocate to Virtual Hard Disk. Remember the same amount of space should be there in our Physical hard disk of PC too. (Example : If you select 200GB than your physical drive should have atleast 220GB free storage) . Minimum storage for Virtual Drive for the Android Building is 100GB but I recommend you to keep above 150GB. You will come to know why later. Select the folder/drive in your physical drive were you want to store Virtual hard drive (VMDK) in your physical hard disk of PC.

    YJci8mw.png


    Q183qwt.png


    8) Now click on Settings and Go To System a Processor Now in Processor Drag the Pointer to End of green line That it specifies the no of Cores you want to allocate to Guest OS. It doesn’t effect to host…:D:D In my case its 2.:eek:

    RIODIn7.png


    ·9) Now go to Acceleration tab next to Processor Tab and Tick Both.


    KAbCX0n.png



    10) Now go to the Settings à Storage à Click on Controller: IDE à next to Click on small CD with + icon mark.

    d9Yddtw.png


    · 11) Navigate to Ubuntu 13.10 64 Bit ISO and select it.


    5thCPCd.png


    S4bxR0b.png




    12) Now go to settings --> System --> boot order --> change it CD/DVD First. ( Or you can directly start the system and press F12 select CD/DVD either will work fine)

    SZldi0e.png


    13) Now Click Start Button to start VirtualBox Guest .
    14) Once Ubuntu Starts you can see following screen with 2 option here you can either test or Install just click Install button to start Installation Process.


    AFgMcaI.png


    · 15)Here It will show what things Ubuntu Requires is available or not and some updates and third party installs if you want you can select ( I never selected it) click continue Here It will show what things Ubuntu Requires is available or not and some updates and third party installs if you want you can select.

    85WlRAQ.png


    16) Here it will show how you want to install the Ubuntu let it be default has shown below since this is under VirtualBox. ( In Windows Dual Boot Different Procedure will be there which will be discussed in next part

    7gaHrqW.png


    17) Select Time Zone , keyboard layout .
    18) Enter the details required.


    VkZavut.png


    ufrVr8I.png



    19) Enter the details required.


    ynfGFTB.png


    20) It will ask to log in to Ubuntu one with Email Id just skip it and continue

    UCnqdks.png



    20) Installation Begins wait until it completes

    msCeMV7.png


    Hurrrray your Linux System is Ready


    275
    Setting Up Build Enviroment For Compiling ROM's

    Installation of Necessary Tools and packages for ROM Development

    1)Installing Java Development Kit (JDK)

    For Kitkat

    Installation of Java V6

    Open The Terminal and Paste following Command

    a) This will Remove the wrong Java JDK from Ubuntu 13.10
    Code:
    [COLOR=#000000]sudo apt-get purge openjdk-\* icedtea-\* icedtea6[COLOR=#007700][COLOR=black]-\*[/COLOR] [/COLOR][/COLOR]


    b) Enter the Following Command and This will Install JDK

    Code:
    wget https://launchpad.net/~webupd8team/+archive/ubuntu/java/+files/oracle-java6-installer_6u45-0%7Ewebupd8%7E8_all.deb sudo dpkg -i oracle-java6-installer_6u45-0~webupd8~8_all.deb wget https://launchpad.net/~webupd8team/+archive/ubuntu/java/+files/oracle-java6-set-default_6u45-0%7Ewebupd8%7E8_all.deb sudo dpkg -i oracle-java6-set-default_6u45-0~webupd8~8_all.deb

    c) Check The Java Version Installed
    Code:
    [COLOR=#000000]java -[COLOR=#0000BB][COLOR=black]version [/COLOR] [/COLOR][/COLOR]

    For Lollipop Required Java Version is 7

    To Install Java V7


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

    :DJava Installation Completes:D

    2)
    Installation Of Required Tools
    Enter The Following Command
    Code:
    sudo apt-get install git-core gnupg ccache lzop flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5 lib32z1 lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z-dev libgl1-mesa-glx:i386 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.8-dev python
    Note : If you get error like broken dependencies then use the following command and then use above command.:D

    Code:
    sudo apt-get update
    Code:
    sudo apt-get upgrade
    After Installation Completes Enter The Following Command
    Code:
    sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
    So The Above Are The Packages

    Now comes the binary called Repo.


    What Is Repo?:rolleyes:

    Repo is a repository management tool that we built on top of Git. Repo unifies the many Git repositories when necessary, does the uploads to our revision control system and automates parts of the Android development workflow.

    Enter The Following Command
    Code:
    mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo
    Using Text Editor Open ~/.bashrc for that use following command
    Code:
    sudo nano ~/.bashrc
    At The Very Bottom Line Add following Line
    Code:
    export PATH=~/bin:$PATH
    Save it. Here To save Press Ctrl+O and Enter and Ctrl+X to exit:)
    Now Enter Following Command
    Code:
    source ~/.bashrc

    :cool::cool:Now Your System Is Ready For ROM Building:D:D
    237
    Downloading Sources

    To build a Rom from Source first we need to download the sources from git.
    Note : Sources will be very huge approx 13GB to 14GB hence lot of patience is required since it will take some time depending on your Internet connection speed.

    So lets start..

    Here i will take the example of cm11.
    The steps goes has follows

    1) Create a directory were your sources will be downloaded. Enter the following command to terminal to create a directory

    Code:
    mkdir cm11
    Now in your Home directory you will see folder called cm11.

    1zEeVvZ.png


    2) The next step is you have to Initiate the repo. meaning of the repo is given above. It will communicate with the git and download the source were it is stored.
    Enter The Following Command to Terminal
    Code:
    cd cm11
    This will take you to the directory you created in Step 1.

    8zCZANO.png

    Now Enter The Following Command Which Will Initiate The Repo :laugh:
    Code:
    [FONT=Arial][SIZE=4]repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0[/SIZE][/FONT]


    AH3P62H.png


    MesK53W.png

    Since i m taking example of cm11 above repo initiate command is used you can find this here for CM11
    Note : All the details for Repo Initiate and Building will be given in respective Source Github. Various Github source links will be given in discription and the end.

    This will initialize your local repository using the CyanogenMod trees.:p:D:D
    now got to cm11 folder and press Ctrl+H this will show the hidden folder .repo were sources will be downloaded.

    WSkXUQr.png


    Buqbjst.png

    Now it might give a small error at the end stating for Email id.
    So just create a github account here
    Then Run following in Terminal
    Code:
    [FONT=Arial][SIZE=4]git config --global user.email "[email protected]"
    git config --global user.name "Your Name"[/SIZE][/FONT]


    replace
    "[email protected]" with your github email Id
    replace
    "Your Name" with github Username

    3) Now To control the files that should be downloaded while sync and for adding device tree we use local_manifest.xml. Reagrding this @Kishan14 will explain in detail with Tips and Tricks.

    4) Now it is the time to download the sources. for that run the following Command

    Code:
    repo sync -j#

    #
    is number of jobs you want to give for your downloading source. I use 2 to 4.

    hEbrLC4.png


    dE5oydZ.png

    Now it will download the Sources needed to build the Rom..Download will be huge 13GB to 14GB so be patient since it depends on your Internet Speed.

    The Above was for CM11 same procedure for other provided you have to replace cm11 with one you want to sync/build like AOSP,AOKP,AICP etc and Repo Initialize command varies with the source you want to download.

    Some Git Links :

    CM11 : https://github.com/CyanogenMod/android
    AOKP : https://github.com/AOKP/platform_manifest
    Carbon Rom : https://github.com/CarbonDev/android
    SlimRom : https://github.com/SlimRoms/platform_manifest
    181
    Building Rom For A Particular Device

    Building Rom For A Particular Device

    Now has we have downloaded the sources we need for our Rom Build Lets Move to the Next Step which is Actually Major Step the Building The ROM

    So Lets Start The Game...:laugh::D:D

    Note : I will be taking Samsung Galaxy Grand Duos - GT -I9082 has Example here.
    Example Rom : CM11

    Now before starting with Building guide you have to Download your Device Identity That is has follows
    1) Device Tree
    2) Vendor
    3) Kernel
    The Above files are very Vital Parameters of building they specify your device and its Characteristics.

    Now you might think from where you have to download those files?
    :confused:
    Don't be confused its simple Search in our device forum for CM Tree and Kernel and Vendor. The Dev of CM for your Device forum will specify it in his ROM thread.
    Once you obtain the github for your Device Tree, Vendor and Kernel. Enter following command
    Code:
    cd cm11/.repo
    Y6KmJsy.png

    Here in .repo folder you have to create file called local_manifests.xml
    1) Enter The Following Command in Terminal
    Code:
    nano local_manifest.xml
    mOFUkXi.png

    Structure of Local_manifest.xml is Has follows.
    Code:
    [COLOR=#000000][COLOR=#0000BB]<?xml version[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"1.0" [/COLOR][COLOR=#0000BB]encoding[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"UTF-8"[/COLOR][COLOR=#0000BB]?>
    [/COLOR]<manifest>
      [/COLOR]<project path=" directory in work tree" name="name of the repository in remote" remote="name of remote defined earlier" revision="branch of the repository" /> 
    [COLOR=#000000]</manifest>[/COLOR]
    2) Add your Device , Kernel , Vendor Source
    gHq689W.png


    Taking my Ex here of GT-I9082
    After Adding device tree , Vendor , kernel my Local_manifest.xml will look like has follows
    Code:
    [COLOR=#000000][COLOR=#0000BB]<?xml version[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"1.0" [/COLOR][COLOR=#0000BB]encoding[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"UTF-8"[/COLOR][COLOR=#0000BB]?>
    [/COLOR]<manifest>
      <project path="device/samsung/i9082" name="pawitp/android_device_samsung_i9082" remote="github" revision="cm-11.0" />
      <project path="vendor/samsung/i9082" name="k2wl/android_vendor_samsung_i9082" remote="github" revision="master" />
      <project path="kernel/samsung/i9082" name="pawitp/android_kernel_samsung_i9082" remote="github" revision="cm-11.0" />
    </manifest>[/COLOR]
    ABoaVKn.png

    3) Press ctrl+O and Enter
    DpbtNWp.png


    ZNqRufc.png

    4) Press Ctrl+X to exit.
    Sx5Onvn.png

    After Adding Device Tree,Vendor,Kernel sources just repo sync again so that the files are downloaded. you can also add which files you want to download or you dont want to download. More about manifest and local_manifest will be explained by @Kishan14 in his guide:D

    Once that is done now you have your device Identity with you:laugh::laugh::highfive:
    Now follow the Instruction Given by @rutvikrvr in POST 9 to make the your CM Device Tree Compatible with your ROM Source.

    Once your CM Device tree is successfully made compatible with your ROM its Time for Building :D:cool:
    Now Building Command Various with Rom which you want to compile its different for different ROM you have to see the Manifest of The Rom for it has instruction for building will be given there. Since i m Taking example of CM11 and Device has GT-I9082 the steps goes has follows
    1) Enter the Following command in Terminal
    Code:
    cd cm11
    Just Replace CM11 by your working directory of Rom . Ex : AOGP,AICP etc
    2)Now enter following Command To Terminal
    Code:
    [COLOR=#000000][COLOR=#007700]. [/COLOR][COLOR=#0000BB]build[/COLOR][COLOR=#007700]/[/COLOR][COLOR=#0000BB]envsetup[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]sh[/COLOR][/COLOR]
    3) Build Instruction Varies from Rom to Rom so check manifest of ROM for the Same. General instuction is
    Code:
    [COLOR=#262626]time brunch <codename>[/COLOR] [COLOR=#000000][COLOR=#007700]-[/COLOR][COLOR=#0000BB]j[/COLOR][COLOR=#FF8000]#[/COLOR][/COLOR]
    <Codename> CodeName of your Device
    # is the No of CPU cores you have.
    Building will take time depending on your system configuration.

    Once building is Done.
    Its Time to apply patches which will be given in our CM Rom thread if any.
    Follow the guide by @rutvikrvr in Post 10 for applying patches.
    Once Done rebuild again using command above (This time building will be fast)

    Now go to your working directory and go to OUT/target/your device/ you will get the Zip of the Rom.
    Always make a backup of your current Rom.
    Flash it via recovery and check.:laugh::laugh:

    :cool::cool:Hurrrrrray You Just Developed A Rom from Source:cowboy::cowboy:
    140
    Uploading Device Tree To Github

    So Guys till now we learnt lot of stuffs and finally we build a Rom :highfive: During building the Rom we may have edited lot of stuffs in device tree :D:D To avoid those being repeated in case you delete the Tree or If your ROM is Unofficial then you have to upload the Device Source Tree to Github. There are lot of uses if you upload the device tree.

    Lets Start with guide Now :D:D

    1) Create a account in Github.

    2) Generate a new SSH key
    Enter Following command to Terminal
    Code:
    ssh-keygen -t rsa -C "[email protected]"
    "[email protected]" = your github Email ID

    After pressing Enter you will Observe the following output
    Code:
    # Creates a new ssh key, using the provided email as a label
    # Generating public/private rsa key pair.
    # Enter file in which to save the key (/home/you/.ssh/id_rsa):
    Press Enter.

    Now you need to enter the passphrase
    Code:
    # Enter passphrase (empty for no passphrase): [Type a passphrase] # Enter same passphrase again: [Type passphrase again]
    Once all done you will see the following in your Terminal.

    Code:
    Your identification has been saved in /home/you/.ssh/id_rsa.
    # Your public key has been saved in /home/you/.ssh/id_rsa.pub.
    # The key fingerprint is:
    # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]
    Now go to ~/.ssh folder and copy your id_rsa.pub content into account administration on github.com.
    That is go to github account settings and SSH
    copy paste id_rsa.pub content there and save it done.:D:cowboy:

    Now Its Time To Check If Everything Works.:highfive:


    • Enter The Following Command To Terminal
      Code:
    • It should display has follows
      Code:
      The authenticity of host 'github.com (207.97.227.239)' can't be established.
      # RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
      # Are you sure you want to continue connecting (yes/no)?
    • type yes and press enter
      Code:
      Hi username! You've successfully authenticated, but GitHub does not
      # provide shell access.
    Now All Done Its Time To Upload The Device Tree To Github :cowboy:

    Example Device and Rom : GT-I9082 and AOGP Rom.
    In the following steps i take my example device and Rom just replace the device with your device and Rom with your Rom:cool:

    Steps :


    • In Terminal
      Code:
      cd aogp/device/samsung/i9082
    IYwxiGJ.png


    MywR13m.png


    • Then Type Following
      Code:
      git init
    VX7TpL2.png


    ovdAnqa.png


    • Setting up of the git files required to push the files to the github account will be done by following command
      Code:
      git add .
    QA1GZTL.png

    • Now we need to comment on the files we are pushing to github hence enter following command
      Code:
       git commit -m "first commit"
    m6TUgMc.png

    • Now Go to your Github account click on add button on top next to your username and Select New repository
    o9hykDa.png

    • enter the Name of your repository in my case you can see the ScreenShot below
    MJrg5oy.png

    • now you can see some commands displayed enter the git link displayed in your repository created the terminal in my case
      Code:
      git remote add origin https://github.com/username/aogp_device_samsung_i9082.git
    q7GtUIv.png


    1mHEHlS.png


    • Last Step is To Push The Source to Github. Enter The Following Command in Terminal
      Code:
      git push origin master
    lxMlsq0.png


    The Passphrase is the same you entered while creating SSH key.

    06SbxM4.png


    • Finally your source is in Github now add Readme.md File and mention This is <ROM NAME> Device Tree For <Your Device>
    :D:cool:You Have Successfully Uploaded your Device Tree To Github :cowboy::cowboy:

    Credits
    @rutvikrvr
    @Kishan14
    @k2wl (My Mentor and Inspiration for Android)


    If You want to learn more about Github and Stuffs you can visit Following Guide by XDA Senior Moderator @eagleeyetom (Thanks a lot Sir)

    Guide Link : http://forum.xda-developers.com/showthread.php?t=1877040