FORUMS
Remove All Ads from XDA

[GUIDE CM11] How to build your own CyanogenMod 11.0 ROM from sources for the Nexus 4

241 posts
Thanks Meter: 730
 
By Raum1807, Senior Member on 6th November 2013, 07:02 PM
Post Reply Email Thread
Make your 'own' KitKat-ROM today!

V1.1 - 20131108 Update 1: Java part added. Error remarks. Local_manifest: branch update.
V1.0 - 20131106 Initial release

Thank you note: Thank you to the whole CM-Team for bringing up-to-date-Android to so many devices.



Overview

I. Preparation
II. Installation of the required packages
III. Installing Java
IV. The sources
V. Building the ROM
VI. Rebuilding with newest sources


I. Preparation

Things you need for building:

A computer
An internet connection
An open mind
Time
Patience

First of all, you need a running up-to-date Ubuntu/Linux system. I am using Ubuntu 13.10 64-bit.

Use the terminal to make the steps. A terminal window can be opened by pressing Ctrl+Alt+T. Every single command for the terminal is marked with a $ sign. Just paste every command (without the $ sign) to your terminal window and there shouldn't be any problem.

IMPORTANT: INSTALL EVERYTHING AS A NORMAL USER. DON'T INSTALL AS ROOT!


II. Installation of the required packages (Ubuntu 13.10 64-bit)

Install packages:
Code:
$ sudo apt-get install bison build-essential curl flex \
g++-multilib gcc-multilib git-core gnupg gperf \
lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev \
libesd0-dev libncurses5-dev libsdl1.2-dev \
libwxgtk2.8-dev libxml2 libxml2-utils lzop \
openjdk-6-jdk openjdk-6-jre pngcrush schedtool \
squashfs-tools xsltproc zip zlib1g-dev
III. Installing Java

You need a version 6 Java Development Kit for building CM11.0. Usually, the SUN JDK 6 is recommended. But there is another way: you can use the OpenJDK 6. When you installed the required packages as described above, you will just need to configure your Java installation.

Check your Java version:
Code:
$ java -version
Verify the symlinks. Javac, Java, Javaws, Javadoc, Javah, Javap and Jar should all point to the right Java location and version:

Code:
$ ls -la /etc/alternatives/java* && ls -la /etc/alternatives/jar
If they are pointing to the wrong versions you have to change that to OpenJDK6.

Select the default Java version for your system:
Code:
$ sudo update-alternatives --config javac 
$ sudo update-alternatives --config java 
$ sudo update-alternatives --config javaws 
$ sudo update-alternatives --config javadoc 
$ sudo update-alternatives --config javah 
$ sudo update-alternatives --config javap 
$ sudo update-alternatives --config jar
That's it.



IV. The sources

Install repo:

Repo is a tool that makes it quite easy to download and maintain the sources of Cyanogenmod.
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ cd ~/bin
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Create the working directory:
Code:
$ mkdir ~/cm11
$ cd ~/cm11
Initialize Repo:
Code:
$ repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
and enter your credentials.

Download the sources:
Code:
$ repo sync
Wait until it's finished - takes some time to download the hefty 12 GB of source code!

Have a break, have a KitKat!

If the process hangs use Ctrl+C to break out of it and resume the download with another
Code:
$ repo sync
If you are running into a lot of syncing errors the reason might be that the 'repo sync' command is establishing four threads automatically. This might be too much. So try to change the command to run with one thread only by using
Code:
$ repo sync -j1
Initialize the environment
Code:
$ . build/envsetup.sh
Obtain the proprietary files:

First get two missing repositories for the Nexus 4 by running
Code:
$ breakfast mako
Then create a file with the name local_manifest.xml in the local_manifests directory. To see this directory, you have to press Ctrl-H in your file manager.

Use this code
Code:
$ gedit ~/cm11/.repo/local_manifests/local_manifest.xml

Update: Branch revision is now cm-11.0
Paste the following lines to the editor
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-11.0"/>
</manifest>
Save the file.

Run
Code:
$ repo sync
again to get the files needed.

Download the necessary prebuilts from cyanogenmod by running
Code:
$ cd ~/cm11/vendor/cm
$ . get-prebuilts
$ croot
And you're done!


V. Building the ROM

Now build it:
Code:
$ brunch mako
And the building process starts. Now have patience. Building takes around half an hour on fast systems and a lot more on older and slower machines.


Update 20131108: The errors from 20131106 are gone now. If you made the changes revert them, sync the repo and then brunch again. There is no need to edit the source at the moment.


YOU ONLY NEED THIS PART IF YOU WANT TO REVERT THE CHANGES YOU MADE BEFORE
As of writing, you will run into two errors:

First error you will encounter:
Code:
build/core/java.mk:23: *** frameworks/support/v4:
Invalid LOCAL_SDK_VERSION '19' Choices are: current 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18.  Stop.
Go to frameworks/support/v4/Android.mk and edit line 128 (it's at the end of the file):
Look for

Code:
# A helper sub-library that makes direct use of KitKat APIs.
include $(CLEAR_VARS)
LOCAL_MODULE := android-support-v4-kitkat
LOCAL_SDK_VERSION := 19
and change the "19" to "current"

It should look like this
Code:
# A helper sub-library that makes direct use of KitKat APIs.
include $(CLEAR_VARS)
LOCAL_MODULE := android-support-v4-kitkat
LOCAL_SDK_VERSION := current
Save the file.

Re-run

Code:
$ brunch mako
The second error you will see:
Code:
build/core/java.mk:23: *** packages/apps/Launcher3:
Invalid LOCAL_SDK_VERSION '19' Choices are: current 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18.  Stop.
Go to packages/apps/Launcher3/Android.mk and edit line 35 (it's in the middle of the file):
Look for
Code:
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/

LOCAL_SDK_VERSION := 19

LOCAL_PACKAGE_NAME := Launcher3
and change the "19" to "current"

It should look like this
Code:
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/

LOCAL_SDK_VERSION := current

LOCAL_PACKAGE_NAME := Launcher3
Save the file.

Re-run

Code:
$ brunch mako
-END OF THE OLD ERROR CORRECTION-


When everything worked as it should you will find your new ROM-image in ~/cm11/out/target/product/mako

It is called cm-11-DATE-UNOFFICIAL-mako-zip. You can flash it via CWM/TWRP as usual.

VI. Rebuilding with newest sources

Whenever you like to update your sources and build a new version you have to run these four simple commands:
Code:
$ cd ~/cm11
$ repo sync
$ . build/envsetup.sh
$ brunch mako
Compiling takes less time than it took for creating the ROM the first time because it's only building new parts while reusing old parts that haven't changed.


Happy building!
The Following 159 Users Say Thank You to Raum1807 For This Useful Post: [ View ] Gift Raum1807 Ad-Free
 
 
6th November 2013, 07:03 PM |#2  
Raum1807's Avatar
OP Senior Member
Thanks Meter: 730
 
More
Reserved
Reserved
The Following 13 Users Say Thank You to Raum1807 For This Useful Post: [ View ] Gift Raum1807 Ad-Free
6th November 2013, 07:32 PM |#3  
hansichen123's Avatar
Senior Member
Thanks Meter: 26
 
More
Nice Tutorial, thank you for the work

Now i have to organize a linux-computer... :/

edited to linux, my brain is out of order today...
The Following User Says Thank You to hansichen123 For This Useful Post: [ View ] Gift hansichen123 Ad-Free
6th November 2013, 07:43 PM |#4  
micku7zu's Avatar
Senior Member
Flag Cluj-Napoca
Thanks Meter: 318
 
More
Thank you for your post. I knew how to compile but I was lazy to compile for myself any rom until now. I planned to wait until someone will post it, but your post just got me excited and I will compile.

Thank you for your instructions and all. Good luck!
The Following User Says Thank You to micku7zu For This Useful Post: [ View ] Gift micku7zu Ad-Free
6th November 2013, 07:56 PM |#5  
B4tnam's Avatar
Member
Flag Adrian, Michigan
Thanks Meter: 10
 
More
This is what I keep getting...
[email protected]:~/cm11$ repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
bash: /home/bruce/bin/repo: Permission denied
The Following User Says Thank You to B4tnam For This Useful Post: [ View ] Gift B4tnam Ad-Free
6th November 2013, 08:04 PM |#6  
Imperticus's Avatar
Senior Member
Thanks Meter: 1,151
 
Donate to Me
More
Quote:
Originally Posted by B4tnam

[email protected]:~/cm11$ repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
bash: /home/bruce/bin/repo: Permission denied

try chmod a+x /home/bruce/bin/repo
The Following 2 Users Say Thank You to Imperticus For This Useful Post: [ View ] Gift Imperticus Ad-Free
6th November 2013, 08:05 PM |#7  
Raum1807's Avatar
OP Senior Member
Thanks Meter: 730
 
More
Quote:
Originally Posted by hansichen123

Nice Tutorial, thank you for the work

Now i have to organize a linux-computer... :/

Gesendet von meinem Transformer Pad mit Tapatalk 4

edited to linux, my brain is out of order today...



If you have a quite new PC running Windows, you could use a virtual machine to install Linux ontop of your Windows installation. Have a look at VirtualBox for example. It's free. https://www.virtualbox.org/
The Following 4 Users Say Thank You to Raum1807 For This Useful Post: [ View ] Gift Raum1807 Ad-Free
6th November 2013, 08:07 PM |#8  
Imperticus's Avatar
Senior Member
Thanks Meter: 1,151
 
Donate to Me
More
@Raum1807 How's cm11? What features have been implemented so far?
The Following User Says Thank You to Imperticus For This Useful Post: [ View ] Gift Imperticus Ad-Free
6th November 2013, 08:10 PM |#9  
micku7zu's Avatar
Senior Member
Flag Cluj-Napoca
Thanks Meter: 318
 
More
Quote:
Originally Posted by B4tnam

[email protected]:~/cm11$ repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
bash: /home/bruce/bin/repo: Permission denied

Of course, because you didn't hit the thanks button. (joking, but of course, just press it now)

Your problem is with folder permissions. I don't know how you created the folders but somehow you just don't have enough permisions now.

Try to:
chmod a+x /home/bruce/bin/repo
The Following 3 Users Say Thank You to micku7zu For This Useful Post: [ View ] Gift micku7zu Ad-Free
6th November 2013, 08:29 PM |#10  
Senior Member
Flag hengelo
Thanks Meter: 82
 
More
Bah my linux box broke.. @op Can you release the cm11 build you made?

Sent from my AOSP on Mako using Tapatalk
The Following User Says Thank You to sjoerd0301 For This Useful Post: [ View ] Gift sjoerd0301 Ad-Free
6th November 2013, 08:35 PM |#11  
Raum1807's Avatar
OP Senior Member
Thanks Meter: 730
 
More
Quote:
Originally Posted by Imperticus

@Raum1807 How's cm11? What features have been implemented so far?

It's work in progress...

It's actually very nice. A bit rough around the corners at the moment... But since KitKat is just a few days old, the progress right now is already fantastic compared to last year's Android 4.2-Release. I am looking forward to the days after the M2 release of CM10.2 when most of the devs will focus on CM11.0. Everything is mostly in English, but the handling is very smooth and my short test didn't reveal anything as not working.

Oh, and a printing feature has been implemented (not tested), new launcher is coming (Launcher 3), etc.

Looks very promising!

The Following 4 Users Say Thank You to Raum1807 For This Useful Post: [ View ] Gift Raum1807 Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes