Disclaimer - About 4Gb+ to download the source for ICS & 10GB+ are so for JB
You will need 25GB (or more) free to complete a single build, and up to 80GB (or more) for a full set of builds.
To compile android you will need an linux distro preferably an Ubuntu-based distributions such as Ubuntu, Linux Mint however, you can use almost any Linux environment as long as you have the right packages and configurations. In this tutorial I will be showing how to use two Linux distributions Arch-Linux and any Ubuntu-based distribution.
To build android you will need a 64bit OS.
For Ubuntu you need either 10.04LTS or 11.10,12.04 futher version may require some more changes so please research this for find out
For Arch you just need the packages below because Arch is awesome like that
Common Setup
1)SDK
May not be needed - [Untested] Please report if it works for you
2) ADB Ubuntu
Note : Also for Arch if android sdk was downloaded
Configure your USB.
Inside of this blank text file insert:
3) Save the file and close it and then issue this command:
ADB Arch if android-sdk hasn't been installed
4) Install the repo:
5) Packages Arch
Pacman
Yaourt
Packages Ubuntu 10.04 - 11.10
Packages Ubuntu 12.04 - 13.04
Sun Java 6
Additional changes needed
On Ubuntu 10.10:
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
On Ubuntu 11.10:
$ sudo apt-get install libx11-dev:i386
On Ubuntu 12.04/13.04:
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
6) Download the source
$ mkdir cm(name it whatever you want)
$ cd into the the directory you just created so for me $ cd cm
For CM10
$ repo init -u git://github.com/Quarx2k/android.git -b jellybean
For CM9
$ repo init -u git://github.com/Quarx2k/android.git -b ics
or
$ repo init -u git://github.com/tpruvot/android.git -b ics
For AOKP JB (Black screen bug unsupported do not build!!)
$ repo init -u git://github.com:Kayant/platform_manifest.git -b jb
For AOKP ICS
$ repo init -u git://github.com:Kayant/platform_manifest.git -b ics
For Slim Bean
$ repo init -u git://github.com/Kayant/platform_manifest.git -b SLIM
For CNA
$ repo init -u git://github.com/Kayant/android_manifest.git -b jellybean
For P.A.C
$ repo init -u git://github.com/Kayant/PAC_android.git -b jellybean
Now
$ repo sync
or
If you have a good connection try this
$ repo sync -j16
If it breaks reduce the number or just
$ repo sync
if you still cant just repo sync
$ repo sync -f
Again if you're still getting errors - A tip from my good friend Pottkopp just leave the pc to sync stop watching those videos, chatting, etc u get the idea because this needs a lot of bandwidth .....
Takes about 2 hours or more for me to sync
7) Ccache
You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products.
Put the following in your .bashrc or equivalent.
export USE_CCACHE=1
By default the cache will be stored in ~/.ccache. If your home directory is on NFS or some other non-local filesystem, you will want to specify the directory in your .bashrc as well.
export CCACHE_DIR=<path-to-your-cache-directory>
The suggested cache size is 50-100GB. You will need to run the following command once you have downloaded the source code:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
When building Ice Cream Sandwich (4.0.x) or older, ccache is in a different location:
prebuilt/linux-x86/ccache/ccache -M 50G
This setting is stored in the CCACHE_DIR and is persistent.
8) Building
All Jellybean roms now use mb526 build for Defy&Defy + thanks to the unified custom kernel
Cyanogenmod -
First you need to download the some stuff or CM won't build -
$ ./vendor/cm/get-prebuilts
If you are getting errors then read this post - here Thanks Skeevy.
Jellybean
$ source build/envsetup.sh && brunch mb526
ICS
$ source build/envsetup.sh && brunch jordan (for defy)
$ source build/envsetup.sh && brunch jordan_plus (for red lense including Defy+)
AOKP JB/ICS -
$ source build/envsetup.sh && lunch
choose aokp_mb526
Slim Bean -
$ source build/envsetup.sh && lunch
choose slim_mb526
CNA -
$ source build/envsetup.sh && lunch
choose cna_mb526
P.A.C
$ ./build-pac.sh mb526 true
Now to Build if the lunch command has been used-
Replace bacon with squish if building CNA
make -j# bacon(# represents double the cores you have on your computer)
So i have two cores so i do make -j4 bacon or you can use mka bacon and the
computer will choose the best one for you
After some hours or minutes if you have a beast of a computer your build should be complete... Well done ^_^
Use the signed zip to update the defy in recovery, don't use the ota package !
File is will be located in ~/out/target/product/mb526
E.g for defy aokp it will be out/target/product/mb526/then aokp_mb526-date.zip.
P.s if you get any errors search this thread first and google then post if you can't find your answer.
Credit and Thanks
Walter79 for his guide and help
Quarx2k, Epsylon3 Maniac103 and the many other moto devs for their work on the motorola devices
Dastin1015 for his guide as am using some of his instructions in this tutorial
Credit and thanks to Google for the guide I used the Ccache setup section from source.andriod.com
You will need 25GB (or more) free to complete a single build, and up to 80GB (or more) for a full set of builds.
To compile android you will need an linux distro preferably an Ubuntu-based distributions such as Ubuntu, Linux Mint however, you can use almost any Linux environment as long as you have the right packages and configurations. In this tutorial I will be showing how to use two Linux distributions Arch-Linux and any Ubuntu-based distribution.
To build android you will need a 64bit OS.
For Ubuntu you need either 10.04LTS or 11.10,12.04 futher version may require some more changes so please research this for find out
For Arch you just need the packages below because Arch is awesome like that
Common Setup
1)SDK
May not be needed - [Untested] Please report if it works for you
- Download the SDK here: http://developer.android.com/sdk/index.html
- Extract the SDK and place it in your home directory.
- I renamed my SDK to android-sdk to make it easier to navigate to.
- Go to your home folder, press Ctrl+H to show hidden files, and open up your .bashrc file.
- Add these lines at the bottom of the file:
Code:
# Android tools export PATH=${PATH}:~/android-sdk/tools export PATH=${PATH}:~/android-sdk/platform-tools export PATH=${PATH}:~/bin
- Find your .profile file and add this at the bottom of the file:
Code:
PATH="$HOME/android-sdk/tools:$HOME/android-sdk/platform-tools:$PATH"
- You have now successfully installed the Android SDK.
- To check for updates issue this into your terminal:
Code:
$ android
2) ADB Ubuntu
Note : Also for Arch if android sdk was downloaded
Configure your USB.
Code:
$ sudo gedit /etc/udev/rules.d/51-android.rules
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"
Code:
$ sudo chmod a+r /etc/udev/rules.d/51-android.rules
ADB Arch if android-sdk hasn't been installed
Code:
[FONT=Trebuchet MS][SIZE=4]$ sudo yaourt -S android-tools [/SIZE][/FONT]
4) Install the repo:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ Reboot your pc.
5) Packages Arch
Pacman
Code:
$ sudo pacman -S perl git gnupg flex bison gperf zip unzip lzop sdl wxgtk \
quashfs-tools ncurses libpng zlib libusb libusb-compat readline schedtool \
optipng python2 perl-switch lib32-zlib lib32-ncurses lib32-readline \
gcc-libs-multilib gcc-multilib lib32-gcc-libs binutils-multilib libtool-multilib
[/SIZE][/FONT]
Yaourt
Code:
[FONT=Trebuchet MS][SIZE=4]$ sudo yaourt -S [/SIZE][/FONT][FONT=Trebuchet MS][SIZE=4]pngcrush sun-java6[/SIZE][/FONT]
Code:
[FONT=Trebuchet MS]$ sudo apt[/FONT][FONT=Trebuchet MS]-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 \[/FONT][FONT=Trebuchet MS]
libxml2-utils xsltproc schedtool pngcrush[/FONT]
Packages Ubuntu 12.04 - 13.04
Code:
$ sudo apt-get install git gnupg flex bison gperf build-essential \
zip bzr 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 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386 schedtool pngcrush
Sun Java 6
Code:
[FONT=Trebuchet MS][SIZE=4]$ sudo apt-get purge openjdk*
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java6-installer[/SIZE][/FONT]
On Ubuntu 10.10:
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
On Ubuntu 11.10:
$ sudo apt-get install libx11-dev:i386
On Ubuntu 12.04/13.04:
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
6) Download the source
$ mkdir cm(name it whatever you want)
$ cd into the the directory you just created so for me $ cd cm
For CM10
$ repo init -u git://github.com/Quarx2k/android.git -b jellybean
For CM9
$ repo init -u git://github.com/Quarx2k/android.git -b ics
or
$ repo init -u git://github.com/tpruvot/android.git -b ics
For AOKP JB (Black screen bug unsupported do not build!!)
$ repo init -u git://github.com:Kayant/platform_manifest.git -b jb
For AOKP ICS
$ repo init -u git://github.com:Kayant/platform_manifest.git -b ics
For Slim Bean
$ repo init -u git://github.com/Kayant/platform_manifest.git -b SLIM
For CNA
$ repo init -u git://github.com/Kayant/android_manifest.git -b jellybean
For P.A.C
$ repo init -u git://github.com/Kayant/PAC_android.git -b jellybean
Now
$ repo sync
or
If you have a good connection try this
$ repo sync -j16
If it breaks reduce the number or just
$ repo sync
if you still cant just repo sync
$ repo sync -f
Again if you're still getting errors - A tip from my good friend Pottkopp just leave the pc to sync stop watching those videos, chatting, etc u get the idea because this needs a lot of bandwidth .....
Takes about 2 hours or more for me to sync
7) Ccache
You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products.
Put the following in your .bashrc or equivalent.
export USE_CCACHE=1
By default the cache will be stored in ~/.ccache. If your home directory is on NFS or some other non-local filesystem, you will want to specify the directory in your .bashrc as well.
export CCACHE_DIR=<path-to-your-cache-directory>
The suggested cache size is 50-100GB. You will need to run the following command once you have downloaded the source code:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
When building Ice Cream Sandwich (4.0.x) or older, ccache is in a different location:
prebuilt/linux-x86/ccache/ccache -M 50G
This setting is stored in the CCACHE_DIR and is persistent.
8) Building
All Jellybean roms now use mb526 build for Defy&Defy + thanks to the unified custom kernel
Cyanogenmod -
First you need to download the some stuff or CM won't build -
$ ./vendor/cm/get-prebuilts
If you are getting errors then read this post - here Thanks Skeevy.
Jellybean
$ source build/envsetup.sh && brunch mb526
ICS
$ source build/envsetup.sh && brunch jordan (for defy)
$ source build/envsetup.sh && brunch jordan_plus (for red lense including Defy+)
AOKP JB/ICS -
$ source build/envsetup.sh && lunch
choose aokp_mb526
Slim Bean -
$ source build/envsetup.sh && lunch
choose slim_mb526
CNA -
$ source build/envsetup.sh && lunch
choose cna_mb526
P.A.C
$ ./build-pac.sh mb526 true
Now to Build if the lunch command has been used-
Replace bacon with squish if building CNA
make -j# bacon(# represents double the cores you have on your computer)
So i have two cores so i do make -j4 bacon or you can use mka bacon and the
computer will choose the best one for you
After some hours or minutes if you have a beast of a computer your build should be complete... Well done ^_^
Use the signed zip to update the defy in recovery, don't use the ota package !
File is will be located in ~/out/target/product/mb526
E.g for defy aokp it will be out/target/product/mb526/then aokp_mb526-date.zip.
P.s if you get any errors search this thread first and google then post if you can't find your answer.
Credit and Thanks
Walter79 for his guide and help
Quarx2k, Epsylon3 Maniac103 and the many other moto devs for their work on the motorola devices
Dastin1015 for his guide as am using some of his instructions in this tutorial
Credit and thanks to Google for the guide I used the Ccache setup section from source.andriod.com
Last edited: