Thread is outdated for 4.3... Working on Update. Thanks for your patience
Contents:
Introduction
Glossary & Linux Quick Guide
Setting up Linux (Dual-Boot Style Setup)
Setting up your Build Environment
Building
Cherry-Picking
Using CCache
Editing Local Manifests/Adding APKs to the build
Bash Scripting Autonomy
Creating Launchers
Uploading
Reserved
1. Introduction
Welcome To The Most Comprehensive Tutorial For Building AOKP ROMs I Can Think Of! All of the tutorials I have found have links to other websites interspersed throughout and are dependent on the other sites keeping their information current. Also, they can be confusing. My goal is to create a single document which, unfortunately, will contain some links but will flow in an orderly manner and include a discussion thread for building AOKP nightlies. The setup I will be describing will be using an Ubuntu - 64bit System. YOU MUST USE 64 BIT TO BUILD/COMPILE ANDROID. That said, I recommend Ubuntu 13.04
PLEASE POST ANY QUESTIONS, COMMENTS OR ITEMS YOU THINK WOULD BE BENEFICIAL IN THE THREAD. If this post has helped you, HIT THANKS and TELL OTHERS where to find the info they need. Post the thread on your G+, Facebook, Twitter Etc Accounts. Let's get the word out! Anyone can build! The goal is to create a community feel to this thread. Beginners to advanced users are welcome!
Here is My version of GAPPS. It will install AOKP Camera (Alongside Stock so You can Keep the Photo Sphere feature), Removes the Old Calendar and installs the newest Play Store Version, ***Play Store Version 4.0.25!!!*** Yay!!!!! The First Time you Flash it you might have to select your default calendars again
Thanks to:
VonEsch
Romanbb
These guys have been indispensable for helping me out when I got started, either pointing me in the right direction or learning together...
2. Glossary & Linux Quick Guide
2. Glossary & Linux Quick Guide
Let's start with some basic terms I will use.
Kang: Internet term meaning to steal.Root: Akin to Android's SuperUserNautilus: Ubuntu's default file managersudo: Terminal Command to perform the request as Root.gksu: Terminal Command to open a program as Root i.e. nautilus, gedit, terminal...Repo: 1. Repository. 2. A Python Script used for synchronization between your local repository and AOKP's server repository.Gerrit: A web based code review system, facilitating online code reviews for projects using the Git version control system.Git: An online system used to store source code and manage version control (branches).jb-mr1: Google's branch name for Jellybean 4.2 (jb-mr1.1 is 4.2.2).Terminal: A Linux command prompt. (Ctrl+Alt+t).Commit: A new feature/fix either implemented (merged) or awaiting review and/or approval (open).Build: A completed ROM. (v) To compile a ROMCherry-Pick: To merge an open commit into your local repository to be incorporated into the build.Nightly: A build containing all the merged commits since the last Official Build.Bash: A simple programming language similar in function to DOS.Distro: Short for distribution. Used to refer to a "flavor" of Linux. Different distros have different pros/cons and abilities.Ubuntu: The Linux distro I use.PPA: A Linux package containing software... sorta' like a windows executable.Clone: To download the contents of an online Git repository folder onto your local machine.Build Box: (Box) The PC you are using to build your ROMs.MBR: Master Boot Record - The Hard Drive's own index.Manifest: An XML file that tells the repo script what to include and where to get it from when it syncs your local repository.URL: Short for Universal Resource Locator... basically a Web address.
Linux Quick Guide:
Show Hidden Files in Nautilus: Ctrl+H
Terminal Keyboard Shortcuts:
Copy: Ctrl+Shift+C
Paste: Ctrl+Shift+V
Break Operation: Ctrl+C
3. Setting up Linux (Dual-Boot Style Setup)
3. Setting up Linux (Dual-Boot Style Setup)
I am using the assumption that you have no dedicated PC to build ROMs. The following method will turn your Windows PC into a Dual-Boot Ubuntu/Windows PC. If you already have a build box, go ahead and skip to post #3. Let's get started.
First you need to download Ubuntu. We're going to download Ubuntu 13.04 64-bit. (By the way, Ubuntu's Version control is Year.Month so 13.04 is the April 2013 version). You can burn the image to a disk or a USB stick (Pen Drive). I'm going to show you how to use a pen drive. *IN EITHER CASE* Make sure your BIOS is set to boot from that device first. Don't forget to switch it back afterward.
You can download Ubuntu here: http://www.ubuntu.com/download/desktop
You can download the pen drive installer here: http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/
OK... Here you're gonna follow the directions for Using the appropriate tools to make your bootable disk. So, Yes I am going to give you some links... but they will be specific, I promise!
To create a bootable DVD: http://www.ubuntu.com/download/help/burn-a-dvd-on-windows
To create a bootable USB stick: http://www.ubuntu.com/download/help/create-a-usb-stick-on-windows
OK.. That done? Great! Moving on...
Another link... But it is fantastic and has pictures! Here you will receive excellent instructions on how to create the dual-boot.
Windows 7
http://www.linuxbsdos.com/2012/05/17/how-to-dual-boot-ubuntu-12-04-and-windows-7/
Windows 7 with 2 hard drives
http://www.linuxbsdos.com/2012/07/2...d-windows-7-on-a-computer-with-2-hard-drives/
Windows 8
http://www.linuxbsdos.com/2012/11/05/dual-boot-windows-8-and-ubuntu-12-10-on-uefi-hardware/
4. Setting up your Build Environment
4. Setting up your Build Environment
OK! Make sure your system is completely functional and up to date, using software updater.
Ready to make a build box? Good!
The following will make life easier and your Box more fun. The following are optional but recommended. All code should be cut and pasted into terminal to prevent typos.
Install proprietary media codecs/libraries:
Code:
sudo apt-get install ubuntu-restricted-extras
Code:
sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update
Code:
sudo apt-get install libdvdcss2
Install VLC Media Player:
Code:
sudo apt-get install vlc
Install "Open in Terminal" Extension. This allows you to open a terminal window in any folder by right click and selecting "Open in Terminal" This is very helpful for cherry picking!!!! ***THIS ONE ISN'T A TERMINAL COMMAND*** Either option will work.
Option #1 Paste this into the address bar of your browser and install in Software Center
Code:
apt:nautilus-open-terminal
Option #2 Paste this into the software center search box and install.
Code:
Nautilus plugin for opening terminals in arbitrary paths
Install gvfs-mtp mount to easily mount and unmount your android 4.2 devices upon plugging in and unplugging: (Not Required for 13.04)
Code:
sudo add-apt-repository ppa:langdalepl/gvfs-mtp
Follow the prompts then:
Code:
sudo apt-get update
Then run software updater
Now, create a file /etc/udev/rules.d/51-android.rules (as the root user) and to copy the following lines in it. must be replaced by the actual username of the user who is authorized to access the phones over USB.
1. Open a Root Access Nautilus Session:
Code:
gksu nautilus
2. Now, Click on File System in the Left Hand Pane, then navigate to etc/udev/rules.d/
3. Now, right click in the folder and Select "Create New Document" then "Empty Document"
4. Name the document 51-android.rules
5. Open 51-android.rules
Paste the following:
Code:
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0666", OWNER="thebytesmasher"
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0666", OWNER="thebytesmasher"
# adb protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0666", OWNER="thebytesmasher"
# adb protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0666", OWNER="thebytesmasher"
# adb protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0666", OWNER="thebytesmasher"
# usbboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0666", OWNER="thebytesmasher"
# usbboot protocol on panda (PandaBoard ES)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0666", OWNER="thebytesmasher"
# adb protocol on grouper (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on grouper (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0666", OWNER="thebytesmasher"
# mtp protocol on the grouper (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e41", MODE="0666", OWNER="thebytesmasher"
## Google
#SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0666", OWNER="thebytesmasher"
## LG Nexus 4
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666", OWNER="thebytesmasher"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", SYMLINK+="android_adb", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
# Google Nexus 7 MTP mode : automatic mount when plugged (all android versions)
ENV{ID_MODEL}=="Nexus_4", ENV{ID_MODEL_ID}=="4ee2", ACTION=="add", RUN+="/usr/bin/sudo -b -u yourlogin /usr/local/sbin/go-mtpfs -allow-other=true /media/Nexus4"
ENV{ID_MODEL}=="Nexus_4", ENV{ID_MODEL_ID}=="4ee2", ACTION=="add", RUN+="/usr/bin/sudo -b -u yourlogin /usr/local/sbin/go-mtpfs -allow-other=true /media/Nexus4"
ENV{ID_MODEL}=="Nexus_7", ENV{ID_MODEL_ID}=="4e41", ACTION=="add", RUN+="/usr/bin/sudo -b -u yourlogin /usr/local/sbin/go-mtpfs -allow-other=true /media/Nexus7"
ENV{ID_MODEL}=="Nexus_7", ENV{ID_MODEL_ID}=="4e42", ACTION=="add", RUN+="/usr/bin/sudo -b -u yourlogin /usr/local/sbin/go-mtpfs -allow-other=true /media/Nexus7"
# Google Nexus 7 MTP mode : automatic unmount when unplugged (all android versions)
ENV{ID_MODEL}=="Nexus_4", ENV{ID_MODEL_ID}=="4ee2", ACTION=="remove", RUN+="/bin/umount /media/Nexus4"
ENV{ID_MODEL}=="Nexus_4", ENV{ID_MODEL_ID}=="4ee2", ACTION=="remove", RUN+="/bin/umount /media/Nexus4"
ENV{ID_MODEL}=="Nexus_7", ENV{ID_MODEL_ID}=="4e41", ACTION=="remove", RUN+="/bin/umount /media/Nexus7"
ENV{ID_MODEL}=="Nexus_7", ENV{ID_MODEL_ID}=="4e42", ACTION=="remove", RUN+="/bin/umount /media/Nexus7"
6. Use the Find and Replace (magnifying glass with pencil) option to find thebytesmasher and replace with your Ubuntu username.
7. Save the file.
Reboot for the above changes to take effect.
** Now to install the required libraries to make your build box work! **
Copy and paste this in terminal:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
After that is done installing do:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Then:
Code:
sudo apt-get install schedtool pngcrush
Next we will make the required directories, get the Repo binary/script, Add repo to the path & give it permissions, initialize the repo binary and download the Manifest, then sync the source. Ready?
Make directory for repo binary:
Code:
mkdir ~/bin
Add that directory to your path:
Code:
PATH=~/bin:$PATH
Download repo binary and place it in the proper directory This has recently changed:
Code:
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
Give repo the proper permissions:
Code:
chmod a+x ~/bin/repo
Create directory for where the AOKP repo will be stored and synced, then go to it:
Code:
mkdir ~/aokp_kk && cd ~/aokp_kk
Notice in the above code how We used && to string together 2 commands.
Initialize the AOKP repo and download the manifest for the KITKAT branch ( -b kitkat):
INITIALIZING REPOSITORY
Init core trees without any device/kernel/vendor :
Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat
Init repo with all devices, kernels and vendors supported by OurROM :
Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,kernel,device,vendor
Init repo only for a particular device :
Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,<devicename>,<vendorname>
for example, to init only trees needed to build mako
Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,mako,lge
Init repo for multiple devices
Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,<devicename1>,<devicename2>,<devicename3>,<vendorname1>,<vendorname2>,<vendorname3>
for example, to init trees needed to build mako and grouper
Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,mako,grouper,lge,asus
Sync AOKP source. This can be sped up by using the -j variable. -j4, -j8, -j16, -j32.. Take the number of THREADS your processor have and multiply by 4. The higher the value, the more multitasking... also the higher the number, the slower your build box will run if YOU try to multitask while using a command with a -j variable. Change the number after -j to your liking:
Code:
repo sync -j8
Go do something else. This will take a LONG time! You will be downloading about 10GB of source code. Then Continue on... At this point I reboot my Linux box... Why Not, Right?
Get it? OK!
5. Building...Finally!
5. Building...Finally!
Now we're going to build our first ROM.
The easiest way is to create the ROM and build it into a zip file in one step. to do this we will use the BRUNCH command.
Later we'll set up bash scripts and launchers to simplify the process.
Open a new terminal in the aokp_jb folder using the right click - open in terminal extension we set up earlier
-OR-
you can open a terminal and do
Code:
cd ~/aokp_jb
Then, I always make sure all my variables are set and the build directory is clear:
Code:
PATH=~/bin:$PATH
Code:
make clobber
Now for the next step, use your -j number you decided on earlier (or try another) and substitute mako (both instances) with the device you want to build for (again, don't forget the "."), -j8 or -j12 are reasonable compromises:
Code:
. build/envsetup.sh && brunch mako aokp_mako-userdebug -j32
That's it... for a basic nightly. Now to watch the progress, you can maximize the Terminal Window and open the edit menu (***By default, the Global Menu is enabled in Ubuntu 13.04, that means that for the current window in focus, if you place your mouse pointer at the top left of the screen, you'll get the menu options for that window) and select "Profile Preferences" under the "Scrolling" tab, select "scroll on output"
Now on to More customizations!
6. Cherry-Picking
6. Cherry-Picking
This is the part that most people really want to know about. What is cherry-picking and how do I do it?
On your local computer, you actually have 2 copies of the online Repo. One is in a hidden directory and the other is the one you work with. That way you can modify your visible local copy and if you want to revert or screw something up, it's usually relatively painless to fix. Cherry-picks modify the visible local directory with the modified/added/deleted information of the cherry. When you revert, you're basically calling back up the information from the hidden directory that has been unchanged.
Here is how to cherry pick:
Open up the AOKP Gerrit at
HTML:
http://gerrit.sudoservers.com/#/q/status:open,n,z
Find a change you want to add.
This is where you want to be careful. If the change has multiple parts (i.e. [1/2]) You'll want to cherry-pick both parts.
____________________________________________________________________________________________________________________________________
This is what the Open Commit will look like:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
____________________________________________________________________________________________________________________________________
Choosing the Commit below the highlight by clicking on the Subject name, The next screen looks like this:
Notice the Commit message, (circled in BLUE) it often contains a brief description of the change.
To the left of the commit message is the basic change info.
***The section entitled Project is the important one.*** This section (Circled in RED) tells you where the cherry pick needs to be downloaded to. For this Commit, it needs to be downloaded to your "/home/YourUserName/aokp_jb/device/asus/grouper" directory.
About halfway down the page, you'll find the download section (Circled in GREEN. Click on the "cherry-pick" label. Now copy the URL underneath by either Ctrl+C or right click and copy.
Now we're going to use the "Open in Terminal" extension we installed earlier. You need to navigate into the aokp_jb/device/asus/grouper directory and right click then select "Open in Terminal" or you can do the same by right clicking on the grouper folder and selecting "Open in Terminal"
____________________________________________________________________________________________________________________________________
Once the terminal is open, paste the URL at the command prompt. Either with a right click and paste or Ctrl+Shift+V.
Press Enter
If successful, You should see this or a similar message:
____________________________________________________________________________________________________________________________________
If you want to cherry pick into the same directory as an active pick, you'll need to commit those changes first:
The easiest way is open a terminal in the folder containing the pick you want to commit and type
Code:
git add -A
then
Code:
git commit -a
Select the files you want to keep and press Ctrl+O (like save) and enter, the Ctrl+X to exit.
When you're done picking go back to the root aokp_jb folder and build!
===================================================================================================================
**In order to sync, you'll need to revert your cherry picks, so sync completes successfully. To do this, type the following in a terminal in each directory you picked into.**
Code:
git reset --hard HEAD && git clean -f && git checkout aokp/jb-mr1
This can also be split up into 3 different commands.
7. Using CCache
7. Using ccache
ccache is a compiler cache for C and C++ that can help make builds faster. It will use space on your Home Partition. The recommended size is 50-100GB. I use 20-30GB and find it speeds up things tremendously. Using ccache is easy. in the root of your build directory (aokp_jb) type the following in Terminal:
Code:
export USE_CCACHE=1
Code:
export CCACHE_DIR=/<path_of_your_choice>/.ccache
Code:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
The 50G is the size you want for your ccache. If you want to watch ccache doing its thing type the following in a new terminal:
Code:
watch -n1 -d prebuilts/misc/linux-x86/ccache/ccache -s
Later, we'll use a script to automate using ccache each time.
8. Editing Local Manifests/Adding APKs
8. Editing Local Manifests/Adding APKs
So, if you've followed this, You've already edited your /home/YourUserName/aokp_jb/.repo/local_manifests/kernel_manifest.xml file. We're going to use this file as our local_manifest.xml. Your default.xml found in the directory platform_manifest is the file that repo uses to sync your local repository. kernel_manifest.xml is a local manifest that adds to your default manifest. We're going to use it to add to and remove from the default manifest. Why is this useful? Well if you want to add something to your build that isn't in AOKP's repository, or replace something that is, you use the local manifest to accomplish this.
Your default.xml defines where on the internets repo can find the base repository (called a remote) for the project you want to add. With some basic deduction, we can see in the following example that the name of the remote is cm and the base repository domain is at https://github.com/:
<remote name="cm"
fetch="https://github.com/"
review="review.cyanogenmod.com" />
Click to expand...
Click to collapse
Understanding how the remote is defined is important because if you want to add projects from a different source, not defined by the default.xml, you'll need to define it in your local manifest. You can name it whatever you want, you'll use that name to call it out in your project path statement.
To add a project that doesn't already exist in default manifest you'd simply add a line to the local manifest (kernel_manifest.xml) like this:
Code:
<project path="packages/apps/CMFileManager" name="CyanogenMod/android_packages_apps_CMFileManager" remote="cm" revision="cm-10.1" />
Defined:
"project path=": this is the local folder the project will sync into/with
"name=": this is the remote location of the repository.
"remote=": this is a call the the remote defined at the head of the manifest.
"revision=": this is the branch of the repository you want.
So in this case:
We are downloading the server repository "android_packages_apps_CMFileManager" from "https://github.com/CyanogenMod/" from the "cm-10.1" branch into our local repository ~/aokp_jb/packages/apps/CMFileManager. GET IT?
So now, whenever we perform a repo sync from the root folder, ~/aokp_jb/packages/apps/CMFileManager will be updated with new commits from CyanogenMod's repository. Cool, huh?
That won't create an app in the build by itself, but it gets us much closer!
In order to tell the AOKP build that you want to build in that app, you need to add it to ~/aokp_jb/build/target/product/core.mk. In this case you add the name of the app "CMFileManager" to the list of Apps in core.mk
Code:
abcc \
apache-xml \
atrace \
bouncycastle \
bu \
cacerts \
CMFileManager \
com.android.location.provider \
com.android.location.provider.xml \
core \
So all we did was add it, plus a space and a back-slash. That's it! Now if we build, CMFileManager will be an available app!
But what if you want to replace an existing app with one from a different repository? You first must remove the AOKP project path, then add the new one as shown above. For this example, we'll say that AOSPs calendar app is different from AOKPs and we want to use AOSPs version. So in kernel_manifest.xml we'll do the following:
Code:
<remove-project name="platform/packages/apps/Calendar" />
<project path="packages/apps/Calendar" name="platform/packages/apps/Calendar" remote="aosp" revision="jb-mr1.1-release" />
See, we removed the standard one, then called out the one we wanted. Since this app has the same name, there is no need to modify any other files. Play with it... See what you can do.
Some applications require other "hooks" like a way to access their settings like CMs LockClock or Chronus. You need to add additional strings and xml settings to create a settings menu in ROM Control.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Adding APKs.
Sometimes it's not possible to build an app in from a repository. In this case, we'll use the APK itself!
OK, This is a little trickier..
First you need a copy of the APK you want to install during the build. Do I need to tell you not to install paid versions unless the ROM is solely for you???
Then copy the APK into ~/aokp_jb/vendor/aokp/prebuilt/common/app
Now we need to modify 2 Files to incorporate the APK into the Build.
The first is ~/aokp_jb/vendor/aokp/prebuilt/Android.mk
You'll need to add the following code (For this example, we'll assume we are adding the DashClock APK):
Code:
include $(CLEAR_VARS)
LOCAL_MODULE := DashClock
LOCAL_MODULE_OWNER := aokp
LOCAL_SRC_FILES := common/app/$(LOCAL_MODULE).apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .apk
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
The next file to edit is ~/aokp_jb/vendor/aokp/configs/common.mk
Here you just need to add DashClock in the same format as the other APKs like this:
Code:
PRODUCT_PACKAGES += \
AOKPtips \
AppWidgetPicker \
DashClock \
LatinImeDictionaryPack \
Microbes \
NovaLauncher \
PerformanceControl \
ROMControl \
Superuser \
su \
SwagPapers \
Torch \
UnicornPorn
That's it. Now when you build you'll see that the APKs you added are built in and annotated as pre-signed!
9. Bash Scripting Autonomy
9. Bash Scripting Autonomy
Bash scripting is an easy tool to create an automated method to perform all of the multi-step functions we've covered already. To create a bash script open a new empty document by right clicking and selecting "create new document", then "empty document". Name it something convenient to the task you want to accomplish with the extension ".sh" like "makemako.sh" Obviously omit the quotes. Open the file.
for a bash script the first line should be:
Code:
#!/bin/bash
Then put all the commands you want in the order you want. For this example, I will show you a script to make a MAKO build incorporating all of the previous elements we've covered so far.
Code:
#! /bin/bash
cd ~/aokp_jb
PATH=~/bin:$PATH
make clobber
export USE_CCACHE=1
wait
export CCACHE_DIR=/home/thebytesmasher/.ccache
wait
prebuilts/misc/linux-x86/ccache/ccache -M 20G
wait
startBuildTimeM=$(date +%r)
. build/envsetup.sh && brunch mako aokp_mako-userdebug -j32
wait
endBuildTimeM=$(date +%r)
echo " "
echo "Build Time: $startBuildTimeM"
echo "Finished: $endBuildTimeM"
cd ~/aokp_jb/out/target/product/mako/
file=$(echo aokp_mako_Purely_Merged*.zip)
cp $file /home/thebytesmasher/Desktop/Latest_Builds/mako/
echo ""
echo "File copy complete"
I used the command "wait" in between operations to ensure they complete prior to commencing the next. Additionally I created Start and Stop variables called "startBuildTimeM" and "endBuildTimeM" to display (echo "") the start and stop times so I can find out exactly how long the build took to make. Also in this command, I specified a ccache size of 20GB.
Next, right-click on the newly created script and go to the permissions tab and select "Allow executing file as a program" as seen below:
Doing this allows you to double click the script and select "Run in Terminal" to execute your script. Later on it will be necessary to have this box checked to allow a launcher to work.
Basically, you can make scripts to automate all of your tasks. The next section, Creating Launchers will simplify the process even more.
**Hint: Put all of your scripts into a folder in your Home directory in a folder to keep them out of the way**
10. Creating Launchers
10. Creating Launchers
What a launcher does: It allows you to create a link that automatically launches your script.
Install the following:
Code:
sudo apt-get install gnome-panel
Then to create a launcher:
Code:
gnome-desktop-item-edit --create-new ~/Desktop
Of course, that gets to be a PITA after awhile... So Why not Create a launcher to make launchers?!!
Create a document called Make New Launcher
Copy & Paste The Following:
Code:
gnome-desktop-item-edit --create-new ~/Desktop
Save the document.
Modify the properties of the document to allow it to be executed as a program.
Move it to your scripts folder.
Open a Terminal.
Paste in the following:
Code:
gnome-desktop-item-edit --create-new ~/Desktop
Now the Make a new launcher window will pop up.
For this Launcher, We're going to select:
Type: Application
Name: Make New Launcher
Command: (Click Browse and navigate to the location where the file you just created is and open it)
Comment: Any Comment you may want
Click on the Springy Platform thing to select a different icon, then click OK.
Now whenever you want to create a new Launcher, just double click the new Icon on your desktop!
For Bash Scripts, You'll want to select "Application in Terminal" for Type. That's it! Now you can make a script for Syncing and for building, make launchers and do it all with one double click!
11. Uploading
11. Uploading
12. Also Reserved
12. Also Reserved
TBS, a very gd thread and guide u had open. I understand it for AOKP. I trying to pull someone source from his github after repo sync from cm source. I goo ard but couldn't find and answer. Pls help me with it. Tks.
orbital_71 said:
TBS, a very gd thread and guide u had open. I understand it for AOKP. I trying to pull someone source from his github after repo sync from cm source. I goo ard but couldn't find and answer. Pls help me with it. Tks.
Click to expand...
Click to collapse
I don't quite understand what you are trying to do, can you elaborate a little please?
Example u already build a rom with all the commit and the stuff u want and u push to github. And i like to pull it all and merge with the latest CM source.
orbital_71 said:
Example u already build a rom with all the commit and the stuff u want and u push to github. And i like to pull it all and merge with the latest CM source.
Click to expand...
Click to collapse
So, you want to make a CM repository, and replace certain CM parts with stuff from another git repository?
TheByteSmasher said:
So, you want to make a CM repository, and replace certain CM parts with stuff from another git repository?
Click to expand...
Click to collapse
Yes..
orbital_71 said:
Yes..
Click to expand...
Click to collapse
Well, I don't build CM... I'm not sure if the directory structure is different..., the concept should be the same though. I'm currently writing the section called editing local manifests (Section 8) It should accomplish the basics of what you want, but there may be other hooks required for whatever you add... Please tell me if this is what you're talking about!
hey man I gotta say I've been building AOKP for a while now. here and there I'd cherry pick so that was easy. recently I was trying to figure out how to get features and apps from other roms like CM over to aokp. CMFilemanager was the first one I wanted to try.
I've followed your guide and my rom is building right now. so far so good. thanks for the guide.
Also the scripting is a great idea. ive been doing that too and it saves a ton of time
To start I will be adding a lot to this over time so dont be upset if I dont have everything.
To open a terminal without finding it in your programs all you need to do is ctrl+alt+t
Heavily used Commands
cd: this command is used to navigate through your directory's. For example if you have a folder named apps on desktop you would type... cd Desktop...then cd apps.
mkdir: this means make directory or folder. For example cd to your directory then do mkdir whatever. Then you can cd right into that directory ever.
pwd: print working directory. This shows you where you are on the filesystem. This helps if your deep in a directory or folders.
ls: this means list. This tells you all the files in your present working directory.
man: this means manual. This prints like a help page in the terminal to guide you on whatever you need. This can be used for many things.
cp: means copy a file or directory
rm and rmdir: remove a file or like rmdir remove a directory.
mv: move a file or directory
The next command is to issue a command. There are a couple of popular ways of doing so.
First
"./": this is to issue or run a command or file that is in your current directory.
Second
"../": this runs the file that is directly above your current directory.
cat: prints a list of provided text files to the screen.
grep or global regular expression print: searches for patterns or a pattern in a list of files. This is great for small editing if thats what your into and so is.....
diff: compares two text files and displays the differences found between the files on the screen.
history: this is very useful. This shows you a list of your recent commands if you forgot the exact command. To select a command on the list use "!". For example if the label for the command is 00 then type "!00". However most linus OS's allow you to use the up arrow and enter key instead.
Also if you guys dont want a full help list using the "man" command you can use this command: --help
Popular Terminal Commands for Android:
adb: also called android debug bridge is used to issue commands to your phone and debug.
Most people use the following:
adb devices: shows what devices are connected to the computer
adb push and pull: can transfer file from computer to phone and vice versa.
if you want to push an apk to your system make sure that apk is in your adb folder and type: "adb push target.apk system/apps"
adb reboot
adb reboot bootloader
adb logcat: if you are either porting, making roms, or just debugging for a dev you need to know how to logcat. Also if you want to just take the log and make it into a txt file to share just issue the following; "adb logcat -d> logcat.txt"
The logcat will go to your adb folder and save as logcat.txt.
fastboot: is a tool used to update the flash filesystem
I use fastboot for a few things including flashing splashes and flashing recoveries. For example:
Take twrp. To flash to htc one you do...
"fastboot flash recovery twrp.img" presuming you are in your fastboot directory in terminal and the recovery.img is in that folder.
Now as you may know htc uses fastboot to unlock and lock the bootloader using the following commands:
"fastboot oem unlock"
"fastboot oem lock"
Of course you should know this by now you need to be in bootloader under fastboot usb mode.
Now to be able to use fastboot and adb u need sdk and java. Lets start.
"sudo apt-get install openjdk-6-jre openjdk-6-jdk icedtea6-plugin"
This will get u java jdk. Sudo means root and apt-get install means terminal is pulling the file from servers and then installing it.
Next you want sdk. So instead of going all around and downloading it just do this.
" wget http://dl.google.com/android/android-sdk_r20-linux.tgz"
Wget means you are "getting the package".And then you want to extract the file.
"tar -xvzf android-sdk_r20-linux.tgz"
Seeing how the file is a tar "tar -xvzf" extracts that tar. Then cd to the sdk folder and you are good to go.
Speaking of compressing and uncompressing files......
tar -zxvf filename.tar.gz
Untar a tarred and compressed tarball (*.tar.gz or *.tgz).
tar -xvf filename.tar
Untar a tarred but uncompressed tarball (*.tar).
gunzip filename.gz
Decompress a zipped file (*.gz" or *.z).
bunzip2 filename.bz2
Decompress a file (*.bz2) zipped with bzip2 compression.
unzip filename.zip
Decompress a file (*.zip).
Next. Processes.
You know hiw windows has task manager with ctrl+alt+delete. Well here is that for terminal.
ps
(=print status) Display the list of currently running processes with their process IDs (PID) numbers.
kill PID
Force a process shutdown. First determine the PID. Use the command "ps".
bg PID
Send the process to the background.The same can be accomplished with z.
any_command&
Run any command in the background the symbol "&" means run the proceeding command in the background.
killall program_name
Kill program or multiple programs by name. This is useful
lpq
Shows your printing queue.
lprm job_number
Remove a printing job "job_number" from the queue. Alot like windows printing task manager.
lpc
Check and control the printer(s). Type "?" to see the list of available commands.
renice -1 PID
(as root) Change the priority of a running process to -1. Make sure you are Root.
*
Ill add more later. My fingers are tired.
Here are some useful admin commands
printtool
Configuration tool for your printer(s).
linuxconfig
(as root, either in text or graphical mode). You can access and change hundreds of setting from it. Be careful.
adduser user_name
Create a new account (you must be root).
userdel user_name
Remove an account (you must be a root).
passwd
Change the password on your current account. If you are root, you can change the password for any user using: "passwd user_name"
chmod perm filename
Change the file access permission for the files you own. You can make a file accessible in three modes: read (r), write (w), or execute (x) to three classes of users: owner (u), group (g), or others (o).
ls -l filename
Checks the files current permissions.
If the file is accessible to all users in all modes it will show:
rwxrwxrwx
The first triplet shows the file permission for the owner of the file, the second for that group, the third for others. A no permission is shown as "-".
su
You will be asked for your password. Type "exit" to return you to your previous login. Don't work on your machine as root. Use it only when you need it.
fdisk
(as root) Linux hard drive partitioning utility. The program gparted I think is better. To install gparted just like many other programs us the command "sudo apt-get install gparted".
fsck -t ext2 /dev/hda2
Check and repair a filesystem.
Instructions For Setting up a Build Environment for Linux
Make sure you are 64-bit
Have a big hard drive
A good amount of ram
If you dont have java already. Get it.
sudo apt-get install openjdk-6-jdk
You will also need python
Code:
sudo apt-get install python
And git
Code:
sudo apt-get install git-core
Android SDK:
I showed you guys how to get it in the first post.
Now open your home folder and press Ctrl+H to show hidden files, and open up a file called .bashrc.
Add these lines to the bottom of .bashrc:
Code:
# Android tools
export PATH=${PATH}:~/SDK/tools
export PATH=${PATH}:~/SDK/platform-tools
export PATH=${PATH}:~/bin
Now you should also find .profile file in the same place you found .bashrc file. Add this to that file:
Code:
PATH="$HOME/SDK/tools:$HOME/SDK/platform-tools:$PATH"
After that you need to install these packages:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc
On Ubuntu 12.04:
Code:
sudo apt-get install git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev x11proto-core-dev \
libx11-dev libreadline6-dev libgl1-mesa-glx \
libgl1-mesa-dev g++-multilib mingw32 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev
Also this:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Now Configure your USB.
Code:
gksudo gedit /etc/udev/rules.d/51-android.rules
A blank text will open and now add this code and save:
Code:
#Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666"
#ASUS
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666"
#Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666"
#Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666"
#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"
Once you have saved the file type this:
Code:
sudo chmod a+r /etc/udev/rules.d/51-android.rules
Now install your repository:
Type the following:
Code:
mkdir ~/bin
PATH=~/bin:$PATH
curl [url]https://dl-ssl.google.com/dl/googlesource/git-repo/repo[/url] > ~/bin/repo
chmod a+x ~/bin/repo
Now all you have to do is initialize your repository and then make a working folder and sync:
mkdir WORKING_FOLDER
cd WORKING_FOLDER
So lets just say you want to sync and build cm10.1 you need the repo so once you cd into the directory type this:
Code:
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1
While that runs in the terminal it is going to ask you to put in your name and email address.
Once all thats done just type:
Code:
repo sync
And your good to go. Thats where I stop for now. Any questions just ask.
How to build a sense kernel from source
Judging that you are reading this and going to try and build a kernel make sure you have looked at the previous posts above as they may be needed to complete this task.
Below is the readme from htc dev's website. But why do all this work. Lets use Linux and bash scripts to our advantage.
Code:
defconfig file: m7wls_defconfig (arm-eabi-4.6)
Download:
=========
If you are not already using an AOSP toolchain (included in an AOSP build tree), download the corresponding official android toolchain for the arm-eabi specified above for this device:
git clone [url]https://android.googlesource.com/platform/prebuilt[/url] for 4.4.3
git clone [url]https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6[/url] for 4.6
(use darwin-x86 in place of linux-x86 for mac)
Build the kernel:
=================
set the following environment variables:
export TOP= [where you installed the toolchain or top of android AOSP code base]
export PATH=$TOP/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH (use corresponding arm-eabi bin path)
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
make [the defconfig file for this device above]
make clean (for subsequent builds)
make -j4 (in this example 4 is the number of processors of your build machine)
Output Binary Files:
====================
After the build process is finished, there should be a file named "zImage" found in arch/arm/boot/
If you are building a rom with this kernel ZImage, copy it into your build's output folder and rename it to "kernel".
You will also need the following kernel modules. These will eventually be installed into /system/lib/modules on the device.
kernel modules:
./driver/*.ko
The only thing I will ask you to get are the following.
-Download the source from htcdev.
-Get your toolchain and put it in your desired folder. Do that with this command.
**On a sidenote you need to know your devices defconfig and what toolchain your device uses. (This is given on the top of the readme as per the one above.)**
Code:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6"
-for me I put the toolchain in my directory like this. It is different for each toolchain and device. It doesn't matter. /android/kernel/**toolchain**. That's where the extracted toolchain is.
-Next step open a file and add the following text. Make sure the file is executable so you can run it. Add this....
echo "~m7wls STOCK KERNEL COMPILER~"
cd Kernel-m7wls
export ARCH=arm CROSS_COMPILE=/android/kernel/toolchain/arm-eabi-4.6/bin/arm-eabi-4.6-
echo "Cleaning up source"
make clean && make mrproper
date +%Y%m%d%H%M > CURRENT_VERSION
echo "Making config"
make m7wls_defconfig
echo "Adding Current Version to Kernel"
cp CURRENT_VERSION .version
echo "Building Kernel"
make -j4
echo "Kernel ready"
cp -f arch/arm/boot/zImage /android/kernel/htcone/STOCK-m7wls/zImage
echo "Copying modules"
rm -f /android/kernel/htcone/STOCK-m7wls/boot.img-ramdisk/lib/modules/*
find . -name "*.ko" -exec cp {} /android/kernel/htcone/STOCK-m7wls/boot.img-ramdisk/lib/modules/ \;
cd /android/kernel/htcone/STOCK-m7wls/boot.img-ramdisk/lib/modules/
for i in $(find . | grep .ko | grep './')
do
echo $i
/android/kernel/toolchain/arm-eabi-4.6/bin/arm-eabi-4.6-strip --strip-unneeded $i
done
echo "Stripped Modules"
echo "All done,Press Enter to Quit"
read ANS
Click to expand...
Click to collapse
-This is a quick script that does all the work for me. No need to add paths, etc. As long as your folders and filed match the paths of the script all will be ok. Now this script will have to be edited to suite your computer and the destinations of your kernel folders.
-Now once the script is fully correct and everything is setup just cd to the directory your script is in and type the following assuming your file name is m7wls type:
Code:
./m7wls
Once the script has fully run. It should take a while in the folders I made you should see zImage and kernel modules. From there you will need to know how to pack the kernel.
Notice if you downloaded sprints htc one kernel source the source is named m7wls-jb-crc-3.4.10-eb45596. I changed this to just m7wls to make it easier for the script.
Finally, remember you will have to make directories to suit the script for example this line "rm -f /android/kernel/htcone/STOCK-m7wls/boot.img-ramdisk/lib/modules/*" this is where the modules go "*" but I had to make these folders first boot.img-ramdisk/lib/modules/.
If you followed my instructions and did your own fooling around you should have a sense kernel built from source. This is not for beginners. If you have any questions just ask. Message me if you really need some more help.
Happy Building!
Reserved just in case.
Im gonna feel tempted for one more if i really want to add to more.
Is anyone finding this guide useful??
Sent from my HTCONE using xda premium