[Android Software/Hacking General [Developers Only]] yuweng:
FAQ

What is AOSP ROM ? What is CAF ROM ? What is HAL ? There are only two types of Android sources, AOSP ROMs uses google source, Eg. here while CAF ROMs uses codeaurora, Eg. here. Do take note that CAF also have different branches, for Eg. AOSPA CAF branch uses 89xx, it won't boot on my MSM8916 or wouldn't even build.

View attachment 4019415

Source

The only custom CAF ROMs that boots on my MSM8916 uses this

View attachment 4019440

Source

Q : How do i know which custom ROMs will build & boot on my Android device ?

A : As RD Santhosh M once told me, you'll never know until you build them & flash it to your device. Generally, from the custom ROM manifest.xml, you'll see whether it is supported. Eg. My Android device uses MSM8916 & if a particular custom ROMs doesn't have that, even though it build but it won't boot. Best is to directly ask the ROM Developer via pm, most of them are active here on XDA or post at their Google+

Q : Which custom ROM shall i build ?

A : Each custom ROM is unique in their own way. i don't plan to review each of them, you'll have to build them & flash it to your device to know its feature. From experience at performance & battery life, 50% is from the kernel & balance is from the ROM, thats why some custom ROMs feels snappier than the other. While some offers custom toolchain too. More info then refer to here

Q : i wanna learn how to build custom ROMs, where do i start ?

A : There are tons of guides here on XDA & elsewhere. Personally, i use BBQLinux, more info then refer to my thread here

Q : i have a slow PC & slow connections

A : Try out Google Cloud for free, more info then refer to nitin.chobhe thread

Misc Tips

Syncing ROM Source

mkdir -p ~/AOSP/LineageOS
cd ~/AOSP/LineageOS
repo init -u git://github.com/LineageOS/android.git -b cm-14.1
repo sync -fcj68 --force-sync

Source Eg. For my kiwi. Each custom ROMs may be different, refer to their manifest for further build info

More info on syncing source here & info on fixing sync corruption here <= Misc Tips

cd ~/AOSP/LineageOS
prebuilts/misc/linux-x86/ccache/ccache -M 100G
export USE_CCACHE=1
export LC_ALL=C
export JAVA_HOME=/usr/lib/jvm/default
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
source build/envsetup.sh
brunch kiwi 2>&1 | tee ~/AOSP/LineageOS/compile.log

My BBQLinux build-script

Fixing build error

From experience after building about forty custom ROMs, most of the time is either the ROM source or device tree. On some custom ROMs, you may need to replace certain projects in order for it to work, more info on using local_manifest.xml. Eg. below

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<[COLOR="Blue"]remove[/COLOR]-project name="android_hardware_qcom_audio" />
<project path="hardware/qcom/audio-caf/msm8916" name="LineageOS/android_hardware_qcom_audio" remote="github" revision="cm-14.1-caf-8916" />

<[COLOR="blue"]remove[/COLOR]-project name="android_hardware_qcom_display" />
<project path="hardware/qcom/display-caf/msm8916" name="LineageOS/android_hardware_qcom_display" remote="github" revision="cm-14.1-caf-8916" />

<[COLOR="blue"]remove[/COLOR]-project name="android_hardware_qcom_media" />
<project path="hardware/qcom/media-caf/msm8916" name="LineageOS/android_hardware_qcom_media" remote="github" revision="cm-14.1-caf-8916" />
</manifest>

If a particular ROM is based on Lineage & Lineage developers there has added a new feature or fix some codes & this particular custom ROM developer haven't updated it yet then most of the time it will cause build error. So either wait for a few days until those changes has been merged then only build again.

Or refer to their github & gerrit to see what are the changes that might causes the build error. Then you can either revert those changes so that the ROM can be build. An Eg. here & the build error hints something about power.h then you can revert the change as below

cd ~/CustomROM/hardware/libhardware
git revert --no-edit [COLOR="Blue"]f29cb1fd95ee6e5b371d2d6a85c1aeac708b19a6[/COLOR]

View attachment 4034126

Every custom ROMs is unique so refer to their device tree for reference. Eg. Custom MSM8916 flags & dependencies on Omnirom for my kiwi

Another common build error & fixes

ninja: error: '/home/yuweng/5x/AOSP/Omni/out/target/product/kiwi/obj/SHARED_LIBRARIES/[COLOR="Blue"]libqmiservices[/COLOR]_intermediates/export_includes', needed by '/home/yuweng/5x/AOSP/Omni/out/target/product/kiwi/obj/EXECUTABLES/[COLOR="blue"]wcnss_service[/COLOR]_intermediates/import_includes', missing and no known rule to make it
make: *** [build/core/ninja.mk:149: ninja_wrapper] Error 1

[COLOR="Red"][B]#[/B][/COLOR] TARGET_USES_QCOM_WCNSS_QMI := true

OR

TARGET_PROVIDES_WCNSS_QMI := true

Either remark it or just delete that whole flag or add an additional new flag above will fix the build error on omnirom.

While some custom ROMs require additional flags for certain feature to work, always refer to their github device tree for reference. For Eg. on my kiwi, on DU, sliding the BT switch won't work, it will switch on but it won't detect nearby bluetooth devices & in a short while, it will auto switch off. All needed was an additional flag

BLUETOOTH_HCI_USE_MCT := true

Source

If you are still not able to solve those build errors or a certain function doesn't work on your device then try asking for help at their google+. Some provide realtime on IRC Freenode too. Eg. TWRP & omnirom, always check out the timezone first. Eg. You should be able to catch hold of Dees_Troy TWRP Lead Developer( very nice & approachable developer ) at 9am to 5pm & there won't be anyone around at 3am in the morning obviously !

Ethics

Gives Credit Where Credit is Due

Over the years, i've seen alot of fights & arguments here on XDA & elsewhere regarding taking the work of others. Most developers already shared/ public their work to the world, all you have to do is to show your gratitude by mentioning their name in your work when you share them, thats all they want, to be acknowledged & recognized for their work ! When you don't meaning you are stealing from them, end users wouldn't have known & they will think that you do all the work all by yourself. Gives Credit Where Credit is Due

Detail info then refer to here & here

Official Support

Most ROM Developers doesn't support devices that they don't own. If you do want to maintain a particular ROM for your device then talk to them & see how to work things out !

Example of a Basic requirement of a Device Maintainer

As a Maintainer you are expected to:

1. Be able to build for your device and provide users with regular builds.
a. You must own the device you wish to maintain. Blind builds and ports are NOT allowed!
b. Exceptions may be made (family/friend's devices with direct access and variants of devices etc) and are to be requested BEFORE submitting your patchset to Gerrit!
c. A Co-Maintainer may be elected for your device by you if wanted. He/she must follow the same rules as you and submit their own commit to Gerrit.
d. Maintainers will have merge permissions to their device and kernel specific repositories and are expected to keep their device in working order. Whether this done by; doing basic upkeep with upstream changes for fixes and updates, starting for an upstream base and doing original work (pushing upstream when you can), or a mixture of both. The main concern is following proper procedure and keeping your device(s) functioning. Additionally, common and shared repositories will be worked on together by the Maintainers; they will still be controlled and merged by the PAC Team. In this respect, teamwork among Maintainers with common devices will not only be encouraged, in some cases, it may be necessary.

2. Threads are to be compared to our templates regularly for updated topic and content changes.
a. Templates are to be used exactly as they are with NO alterations aside the foreseen places like Title, Installation, Updating, Not working, Other info, and additional credits below the current list if any, unless permitted otherwise.
b. Custom additions (custom builds, kernels, patches, software packages etc) are tolerated and may be distributed from the PAC-ROM thread's Downloads section of the first post.
c. Information about any custom additions is to be posted in the 2nd post of both threads.
d. Custom additions are your responsibility, and are not supported by the PAC-ROM Dev Team.
e. The PAC-ROM Dev Team may change, remove, disable, or tell you to delete ANY custom additions or infringing content for any reason, at any time, in our sole discretion.
f. If unsure, ask the reviewer you contacted.

3. Maintainers MUST create an account on our [JIRA] (http://jira.pac-rom.com/). Users will be able to submit issues and find contact information on the Maintainer for their device such as PAC/XDA Threads. Maintainers will be required to upkeep their JIRA support.

4. To maintain proper support and device usability across the PAC-ROM community, if a device is: abandoned, unsupported, unkempt, or devices where the Maintainer has; sold, broken, lost, no longer has and will not be replacing [within the grace period of 4 weeks], or no longer cares to maintain the device for PAC, then the device will be removed. Remember, if the device is removed and it gets further support, from someone else, then it can be resubmitted later as new.
a. Be fair to the users, if you can not maintain the device anymore for whatever reason, please try to find a follow up maintainer, have them submit their take over changes to Gerrit, and have your threads transferred if possible. If this is not possible, please remove the device and submit your cleanup to Gerrit.

5. Prereleases

* Only Maintainers may publish Alpha/Prerelease builds.
* Alpha/Prerelease build version tag should be set to UNOFFICIAL
* Users/Unofficial device Maintainers may NOT release/post our Prerelease builds.
* Permission for Maintainers may be revoked anytime for a Maintainer or global for all Maintainers.
* Alpha/Prerelease builds are to be uploaded to BB/codename/Unofficial.
* Alpha/Prerelease builds are NOT supported by PAC Dev Team or Maintainers.
* Maintainers are to check their XDA device category for threads posting Prereleases/Unofficial builds and have them removed/closed.
* Maintainers can use this opportunity to test and bring up their devices, users can play with cutting edge test builds and return feedback for the Maintainer at their own risk.
* Community/Forum posts about ETA's, Prerelease device compatibility, broken or missing features, or any other acquisition of Prerelease information and support will be deleted/directed toward the Maintainer.

6. As a Maintainer, you will be able to:

* Get official, clean built, and automated nightly/weekly builds from Jenkins.
* Use our file hosting for builds.
* Use our OTA for pushing your own builds.
* Join in on our discussions, get support from the Dev Team and other Maintainers.
* There is no cake, it's a lie!
* Devices that get less than 35 downloads a week are considered low activity and will be moved to weekly.xml.

7. This page is subject to change without notice! Check back regularly here for changes.[/hide]

Original Source

Build Server

Recently a good friend of mine shoxxy from Germany is so kind for letting me try out his build server... :good: :cowboy:

View attachment 4071930

repo sync completed in about 35 minutes only instead of 8 to 10 hours on my home 10MB broadband !

View attachment 4071931

speedtest 200MB/s while my home typically only 8 to 9MB/s !

How this works is that you are actually still using your PC to connect to the build server via terminal ssh, Eg. ssh yuweng@xxx.xxx.xxx.xxx & you'll be prompt for password. shoxxy has already setup the OS so i only need to sync the source & start building ! There is absolutely no GUI only command line so you need to be familiar with nano to edit your device tree.

View attachment 4071955

Copy/ paste from your PC to build server terminal works. Some of the common nano shortcut key is ctrl + k = cut & ctrl + u = paste or you can also use your mouse to highlight that particular line then ctrl + k to cut it & copy whatever you need to replace from your PC to the terminal & right-click mouse to paste it. More info on nano keyboard commands

View attachment 4071985

Build completed successfully. You can also use gdrive to upload your build to google drive... :good:

View attachment 4071988

Use nano to check for build error. nano shortcut key to end of file is Ctrl + w + v

View attachment 4071992

Very important to use screen before you start building or your build will stop when connection is lost !

View attachment 4072929

You can even connect directly from your Android device too ! :cool: