[GUIDE] Building CyanogenMod 10.2 for Nexus 4 with Ubuntu 13.04 x64 + NIGHTLIES

Search This thread

klvnhng

Senior Member
Dec 1, 2012
858
371
Toronto
If you are looking for my nightly builds, you can find them here.

RBOyXhm.jpg


NOTE: Official nightly builds for CM 10.2 are now available! Get them here.

So after countless hours of frustration and face-desking, I finally managed to make a working build of CyanogenMod 10.2 (Android 4.3). To make the process slightly less painful for you, I've decided to create this noob-friendly guide. This is my first development guide, so feel free to leave criticism or suggestions through PM.


Prerequisites

You will need:
  • A relatively recent computer running Ubuntu with a reasonable amount of RAM (I recommend at least 4 GB) and around 35 GB of free hard drive storage
  • A decent internet connection
  • Some understanding of basic Android and Linux operation and terminology is helpful
NOTE: This guide is for Ubuntu 13.04 x64, but should work with other relatively recent versions of Ubuntu as well; i.e. 12.04, 12.10.


Setting up the build environment

The first thing you need to do is install the correct Java Development Kit/JDK, Oracle Java 6. If you have OpenJDK installed, you have to uninstall it by typing this command into the terminal, which can be brought up by pressing Ctrl+Alt+T or searched for in the dash.
Code:
sudo apt-get purge openjdk*

To install Oracle Java 6, type this into the terminal (one line at a time):
Code:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer
y

Android SDK requires the x32 compatability packages, ia32-libs. Install it by entering this:
Code:
sudo apt-get install ia32-libs
y

Now you will need to get the Android SDK/Software Developer Kit, if you haven't already. Go ahead and download it here.

Extract it to a folder of your choice (in this guide, I will refer to it as ~/android/sdk) and from that folder, enter these commands into the terminal:
Code:
cd ~/android/sdk/adt-bundle/sdk/tools
./android sdk

Click Install packages. cd to ~/android/sdk/adt-bundle/sdk/platform-tools and type:
Code:
adb
fastboot

If you've done everything correctly, you should get a big block of text for both (which list all of the adb/fastboot commands).

Next, install the build packages. Copy and paste this command into the terminal:
Code:
sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev pngcrush schedtool libxml2 libxml2-utils xsltproc g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib
y

You will now need to set up the directories for your build environment. Type this into the terminal:
Code:
mkdir -p ~/bin
mkdir -p ~/android/cm-10.2

Set up the repo binary (used for syncing your local repository with the CM source):
Code:
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

NOTE: In order to run the repo command when you're not in ~/bin (the folder where you saved the repo binary), you need to add it to your path of execution. To do this, type:
Code:
gedit ~/.bashrc
And then add the line
Code:
export PATH=${PATH}:~/bin
to the top of the file and click save. You can do the same for the adb and fastboot commands by adding
Code:
export PATH=${PATH}:~/android/sdk/adt-bundle/sdk/tools
export PATH=${PATH}:~/android/sdk/adt-bundle/sdk/platform-tools
to the file.


Syncing your local repository with the CM source

The next step is to initialize the repository and download the CM source code to your computer. Type the following lines into the terminal:
Code:
cd ~/android/cm-10.2
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
repo sync

You have now begun downloading all of the CM source code to your build directory. Depending on your internet speed, this can take up to a couple of hours. If the sync interrupts, don't worry. Simply continue the sync (you don't have to restart completely, only the project you were downloading when the interrupt occured, phew) by entering:
Code:
repo sync

Remember, you need to cd into your build directory (~/android/cm-10.2, if you've been following this guide) for the command to work.

Go and get yourself a drink or something, this step takes a long time.

NOTE: If the sync gets stuck at 99%, stop the sync (exit the terminal window), open up a new one, cd to your build directory, and type the following:
Code:
repo sync -j1
This reduces the amount of threads/connections to 1 for the final unsynced project(s). It should work.


Now comes the fun part: Building

You're almost to the end! In order to make a working build, you have to get the proprietary files (mainly device build files and drivers) for the Nexus 4. The easiest way to do this is to create a file named "roomservice.xml" in the ~/android/cm-10.2/.repo/local_manifests directory. Now, .repo is a hidden directory, so in order to access that directory you can either 1) show hidden files and folders in Nautilus (the Ubuntu file manager) or 2) access the folder and create the file using terminal commands. Both methods are explained below (2 is probably easier, but does not always work, in my experience).

1) Open up a Nautilus window. Navigate to your build directory (once again, ~/android/cm-10.2) and press Ctrl+H. This allows you to see hidden files and folders. You should see a folder labelled .repo. Enter it and inside, create a directory called "local_manifests", if there isn't already one. Enter that folder and create a blank file called "roomservice.xml". Next, copy the following lines into the file and press save:
Code:
<manifest>
<project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-10.2"/>
</manifest>

2) Type this into the terminal:
gedit ~/android/cm-10.2/.repo/local_manifests/roomservice.xml
ext, copy the following lines into the file and press save:
Code:
<manifest>
<project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-10.2"/>
</manifest>
If you get an error, try method 1.

Do another repo sync:
Code:
repo sync

After this, you can download the necessary pre-built apps:
Code:
~/android/cm-10.2/vendor/cm/get-prebuilts

Finally, you will build. If you aren't there already, cd to your build directory and run the following commands in the terminal:
Code:
. build/envsetup.sh
brunch mako

Now, just let your computer do the rest. This step is very demanding for your computer, so I recommend you leave it alone while it builds. Go get another drink.

Done? If everything went correctly, cd to ~/android/cm-10.2/out/target/product/mako and you should see your newly built ROM entitled:
cm-10.2-20xxxxxx-UNOFFICIAL-mako.zip

Congratulations! You've successfully built CM 10.2!


For re-builds (i.e. when the source code has been updated and you would like to make a new nightly), just do this:
Code:
cd ~/android/cm-10.2
make clean [I](for incremental builds, you can skip this step. You can also do make clobber; thanks   [user=4520802]@obtained[/user])[/I]
repo sync
. build/envsetup.sh
brunch mako

If you ever encounter an error or problem and need help, feel free to post here or send me a PM.

Happy building, everyone!


Sources:

How To Build CyanogenMod Android for Google Nexus 4 ("mako")
http://wiki.cyanogenmod.org/w/Build_for_mako

[GUIDE] How to build CM10.1 (Android 4.2.1) for the Nexus 4 (mako)
http://forum.xda-developers.com/showthread.php?t=2047981

[GUIDE] Building CM10.2 for Nexus 4 with Mac OS X 10.8.X)[UPDATED: 8.8.2013]
http://forum.xda-developers.com/showthread.php?t=2087318

UBUNTU 12.04 - INSTALL ANDROID TOOLS (ADB, FASTBOOT, ...)
http://bernaerts.dyndns.org/linux/245-ubuntu-precise-install-android-sdk
 
Last edited:

Chekhn

Senior Member
Oct 7, 2012
92
8
Uppsala
Other phones

Very nice guide, but i was wondering if this is working for other phones too? Which i think it does but i was kind of wondering about this part "Now comes the fun part: Building", i want to do this on samsung galaxy s2 (gt-i9100), will i write the same things (execpt from bunch mako)?
 

Cheerpipe

Senior Member
Dec 6, 2010
92
66
You missed the "repo sync" command after creating roomservice.xml file, it is necessary to download the device specific files. (sorry my english)
 

klvnhng

Senior Member
Dec 1, 2012
858
371
Toronto
Very nice guide, but i was wondering if this is working for other phones too? Which i think it does but i was kind of wondering about this part "Now comes the fun part: Building", i want to do this on samsung galaxy s2 (gt-i9100), will i write the same things (execpt from bunch mako)?

You'd also need the correct proprietary (device-specific) files. I'm not sure that TheMuppets has the files for the i9100. You may need to extract them from a working build of CM yourself.

You can check out CM's guide for your device here: http://wiki.cyanogenmod.org/w/Build_for_i9100

Sent by carrier pigeon
 

Chekhn

Senior Member
Oct 7, 2012
92
8
Uppsala
You'd also need the correct proprietary (device-specific) files. I'm not sure that TheMuppets has the files for the i9100. You may need to extract them from a working build of CM yourself.

You can check out CM's guide for your device here: http://wiki.cyanogenmod.org/w/Build_for_i9100

Sent by carrier pigeon

I have checked the CM build guide, but i don't get the zip file when i do cd $OUT, have been searching but no answer and I can't find any threads or posts with this problem.
 
Last edited:

klvnhng

Senior Member
Dec 1, 2012
858
371
Toronto
I have checked the CM build guide, but i don't get the zip file when i do cd $OUT, have been searching but no answer and I can't find any threads or posts with this problem.

You probably didn't get the device blobs correctly. I did a search for the i9100 and it turns out that TheMuppets repo does have it.

So for roomservice.xml:
Code:
<manifest>
<project name="TheMuppets/proprietary_vendor_samsung" path="vendor/samsung" remote="github" revision="cm-10.2" />
</manifest>

And when building:
Code:
brunch i9100
 

obtained

Senior Member
Feb 29, 2012
697
407
35
Tulsa
You'd also need the correct proprietary (device-specific) files. I'm not sure that TheMuppets has the files for the i9100. You may need to extract them from a working build of CM yourself.

You can check out CM's guide for your device here: http://wiki.cyanogenmod.org/w/Build_for_i9100

Sent by carrier pigeon

TheMuppets does have i9100 proprietary files.

Edit: looks like I'm 1 minute late. :)
Also: make clobber and make clean are the same for cm. "make clobber" actually does a "make clean".

Sent from my Nexus 4 using xda premium
 
Last edited:
  • Like
Reactions: Chekhn and klvnhng

Galaxo60

Senior Member
May 25, 2012
2,315
872
@klvnhng

Are you sure we can make this with Java 7?. I tried some days ago to build AOSP and some other ROM´s, and I had so much problems becasue of the Java version when building. I had Java 7, but specifically the build asked for Java 6, so I had to downgrade.

Another question would be if it is necessary to download the code for all the devices, instead of downloading the code just for Mako.

Thanks.

:D
 
  • Like
Reactions: klvnhng

klvnhng

Senior Member
Dec 1, 2012
858
371
Toronto
@klvnhng

Are you sure we can make this with Java 7?. I tried some days ago to build AOSP and some other ROM´s, and I had so much problems becasue of the Java version when building. I had Java 7, but specifically the build asked for Java 6, so I had to downgrade.

Another question would be if it is necessary to download the code for all the devices, instead of downloading the code just for Mako.

Thanks.

:D

Hmm...you may be correct. I have both 6 and 7 installed, so it could be that I'm actually using 6.

Edit: JDK 6 is required (http://source.android.com/source/initializing.html). I have a mixed environment.

And yes, in order to build CM, you need to have the entire source repo synced. Sorry :p
 
Last edited:

VoiD_Dweller

Senior Member
Aug 5, 2011
945
897
Orlando, FL
Let me know how it goes!

Got the build done.. flashed it, flashed gapps, everything works excellent!

One thing though, I noticed the build size of the zip is 9 mb larger than the official nightly for yesterday. Whats up with that?

Also what are the perks of building on ubuntu 13.04 vs the recommended 12.04 I always see in the other guides? are the tools more optimized or something? I'm a linux newb so excuse me if it's a lame question ;)

---------- Post added at 08:06 AM ---------- Previous post was at 08:05 AM ----------

Noob's question ; what are the differences between a home compiled rom and the rom you can download on the CM website ?

You built it, and you don't have to wait for their build server. Also after you learn more about it, you can customize and add things of your own.. basically.
 

klvnhng

Senior Member
Dec 1, 2012
858
371
Toronto
Got the build done.. flashed it, flashed gapps, everything works excellent!

One thing though, I noticed the build size of the zip is 9 mb larger than the official nightly for yesterday. Whats up with that?

To be honest, I'm not quite sure. My builds average 206 MB.

Also what are the perks of building on ubuntu 13.04 vs the recommended 12.04 I always see in the other guides? are the tools more optimized or something? I'm a linux newb so excuse me if it's a lame question ;)

Apparently, the 3.8 kernel included in 13.04 handles tasks more efficiently. There are other optimizations as well, I'm sure. Most people recommend 12.04 because it is a LTS version and therefore will have bug fix and security updates for for 5 years, as opposed to 9 months. But I like to keep up-to-date :good:
 
  • Like
Reactions: VoiD_Dweller

Top Liked Posts

  • There are no posts matching your filters.
  • 32
    If you are looking for my nightly builds, you can find them here.

    RBOyXhm.jpg


    NOTE: Official nightly builds for CM 10.2 are now available! Get them here.

    So after countless hours of frustration and face-desking, I finally managed to make a working build of CyanogenMod 10.2 (Android 4.3). To make the process slightly less painful for you, I've decided to create this noob-friendly guide. This is my first development guide, so feel free to leave criticism or suggestions through PM.


    Prerequisites

    You will need:
    • A relatively recent computer running Ubuntu with a reasonable amount of RAM (I recommend at least 4 GB) and around 35 GB of free hard drive storage
    • A decent internet connection
    • Some understanding of basic Android and Linux operation and terminology is helpful
    NOTE: This guide is for Ubuntu 13.04 x64, but should work with other relatively recent versions of Ubuntu as well; i.e. 12.04, 12.10.


    Setting up the build environment

    The first thing you need to do is install the correct Java Development Kit/JDK, Oracle Java 6. If you have OpenJDK installed, you have to uninstall it by typing this command into the terminal, which can be brought up by pressing Ctrl+Alt+T or searched for in the dash.
    Code:
    sudo apt-get purge openjdk*

    To install Oracle Java 6, type this into the terminal (one line at a time):
    Code:
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java6-installer
    y

    Android SDK requires the x32 compatability packages, ia32-libs. Install it by entering this:
    Code:
    sudo apt-get install ia32-libs
    y

    Now you will need to get the Android SDK/Software Developer Kit, if you haven't already. Go ahead and download it here.

    Extract it to a folder of your choice (in this guide, I will refer to it as ~/android/sdk) and from that folder, enter these commands into the terminal:
    Code:
    cd ~/android/sdk/adt-bundle/sdk/tools
    ./android sdk

    Click Install packages. cd to ~/android/sdk/adt-bundle/sdk/platform-tools and type:
    Code:
    adb
    fastboot

    If you've done everything correctly, you should get a big block of text for both (which list all of the adb/fastboot commands).

    Next, install the build packages. Copy and paste this command into the terminal:
    Code:
    sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev pngcrush schedtool libxml2 libxml2-utils xsltproc g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib
    y

    You will now need to set up the directories for your build environment. Type this into the terminal:
    Code:
    mkdir -p ~/bin
    mkdir -p ~/android/cm-10.2

    Set up the repo binary (used for syncing your local repository with the CM source):
    Code:
    curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo

    NOTE: In order to run the repo command when you're not in ~/bin (the folder where you saved the repo binary), you need to add it to your path of execution. To do this, type:
    Code:
    gedit ~/.bashrc
    And then add the line
    Code:
    export PATH=${PATH}:~/bin
    to the top of the file and click save. You can do the same for the adb and fastboot commands by adding
    Code:
    export PATH=${PATH}:~/android/sdk/adt-bundle/sdk/tools
    export PATH=${PATH}:~/android/sdk/adt-bundle/sdk/platform-tools
    to the file.


    Syncing your local repository with the CM source

    The next step is to initialize the repository and download the CM source code to your computer. Type the following lines into the terminal:
    Code:
    cd ~/android/cm-10.2
    repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
    repo sync

    You have now begun downloading all of the CM source code to your build directory. Depending on your internet speed, this can take up to a couple of hours. If the sync interrupts, don't worry. Simply continue the sync (you don't have to restart completely, only the project you were downloading when the interrupt occured, phew) by entering:
    Code:
    repo sync

    Remember, you need to cd into your build directory (~/android/cm-10.2, if you've been following this guide) for the command to work.

    Go and get yourself a drink or something, this step takes a long time.

    NOTE: If the sync gets stuck at 99%, stop the sync (exit the terminal window), open up a new one, cd to your build directory, and type the following:
    Code:
    repo sync -j1
    This reduces the amount of threads/connections to 1 for the final unsynced project(s). It should work.


    Now comes the fun part: Building

    You're almost to the end! In order to make a working build, you have to get the proprietary files (mainly device build files and drivers) for the Nexus 4. The easiest way to do this is to create a file named "roomservice.xml" in the ~/android/cm-10.2/.repo/local_manifests directory. Now, .repo is a hidden directory, so in order to access that directory you can either 1) show hidden files and folders in Nautilus (the Ubuntu file manager) or 2) access the folder and create the file using terminal commands. Both methods are explained below (2 is probably easier, but does not always work, in my experience).

    1) Open up a Nautilus window. Navigate to your build directory (once again, ~/android/cm-10.2) and press Ctrl+H. This allows you to see hidden files and folders. You should see a folder labelled .repo. Enter it and inside, create a directory called "local_manifests", if there isn't already one. Enter that folder and create a blank file called "roomservice.xml". Next, copy the following lines into the file and press save:
    Code:
    <manifest>
    <project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-10.2"/>
    </manifest>

    2) Type this into the terminal:
    gedit ~/android/cm-10.2/.repo/local_manifests/roomservice.xml
    ext, copy the following lines into the file and press save:
    Code:
    <manifest>
    <project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-10.2"/>
    </manifest>
    If you get an error, try method 1.

    Do another repo sync:
    Code:
    repo sync

    After this, you can download the necessary pre-built apps:
    Code:
    ~/android/cm-10.2/vendor/cm/get-prebuilts

    Finally, you will build. If you aren't there already, cd to your build directory and run the following commands in the terminal:
    Code:
    . build/envsetup.sh
    brunch mako

    Now, just let your computer do the rest. This step is very demanding for your computer, so I recommend you leave it alone while it builds. Go get another drink.

    Done? If everything went correctly, cd to ~/android/cm-10.2/out/target/product/mako and you should see your newly built ROM entitled:
    cm-10.2-20xxxxxx-UNOFFICIAL-mako.zip

    Congratulations! You've successfully built CM 10.2!


    For re-builds (i.e. when the source code has been updated and you would like to make a new nightly), just do this:
    Code:
    cd ~/android/cm-10.2
    make clean [I](for incremental builds, you can skip this step. You can also do make clobber; thanks   [user=4520802]@obtained[/user])[/I]
    repo sync
    . build/envsetup.sh
    brunch mako

    If you ever encounter an error or problem and need help, feel free to post here or send me a PM.

    Happy building, everyone!


    Sources:

    How To Build CyanogenMod Android for Google Nexus 4 ("mako")
    http://wiki.cyanogenmod.org/w/Build_for_mako

    [GUIDE] How to build CM10.1 (Android 4.2.1) for the Nexus 4 (mako)
    http://forum.xda-developers.com/showthread.php?t=2047981

    [GUIDE] Building CM10.2 for Nexus 4 with Mac OS X 10.8.X)[UPDATED: 8.8.2013]
    http://forum.xda-developers.com/showthread.php?t=2087318

    UBUNTU 12.04 - INSTALL ANDROID TOOLS (ADB, FASTBOOT, ...)
    http://bernaerts.dyndns.org/linux/245-ubuntu-precise-install-android-sdk
    5
    Hello Guys,

    can someone explain me how I can remove Apps before I build the rom? there are several apps those I just not need.... the email app for example.

    Look at /.repo/manifest.xml and search for the app name you want to remove then add something like the line below to /.repo/local_manifests/roomservice.xml :
    Code:
    <remove-project name="CyanogenMod/android_packages_apps_Email" />
    3
    m having this error while setting up in freshly installed ubuntu 13.10

    Code:
    [email protected]:~/android/cm-10.2$ repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
    /home/brajesh/bin/repo: line 1: syntax error near unexpected token `newline'
    /home/brajesh/bin/repo: line 1: `<!DOCTYPE html>'
    [email protected]:~/android/cm-10.2$

    You downloaded an HTML file instead of the command. Don't worry, happened to me also.
    Instead of
    Code:
    curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
    chmod a+x ~/bin/repo
    do
    Code:
    curl [COLOR="Red"]http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo[/COLOR]
    chmod a+x ~/bin/repo

    (as mentioned by @chasmodo)

    I think the original post should be updated with this information.
    2
    Nice tutorial mate.

    Do you guys know where I change CyanogenMod Version and Build Nuber strings?

    If you want to make changes pre-build, I believe you have to use Git (which I am not too familiar with, sorry). Otherwise, you can directly edit build.prop.

    Edit: You can check out eagleeyetom's guide here: http://forum.xda-developers.com/showthread.php?p=31304826

    Also, thanks to @obtained for answering some of the more technical questions. Even though I wrote this guide, there is still a LOT of stuff for me to learn as well.
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone