[Android Software Development] TheByteSmasher:
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:

sudo apt-get install ubuntu-restricted-extras

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

sudo apt-get install libdvdcss2

Install VLC Media Player:

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

apt:nautilus-open-terminal

Option #2 Paste this into the software center search box and install.

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)

sudo add-apt-repository ppa:langdalepl/gvfs-mtp

Follow the prompts then:

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:

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:

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

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:

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Then:

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:

mkdir ~/bin

Add that directory to your path:

PATH=~/bin:$PATH

Download repo binary and place it in the proper directory

This has recently changed

:

curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

Give repo the proper permissions:

chmod a+x ~/bin/repo

Create directory for where the AOKP repo will be stored and synced, then go to it:

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 :

repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat

Init repo with all devices, kernels and vendors supported by OurROM :

repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,kernel,device,vendor

Init repo only for a particular device :

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

repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,mako,lge

Init repo for multiple devices

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

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:

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!