• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

Guide on building Lollipop for the OnePlus One

Search This thread

GRMrGecko

Senior Member
Dec 15, 2012
62
71
31
Huntsville
mrgecko.org
Today I went about and built a copy of CM12 for my phone so that I can control when I get updates and I can get the most latest update. There was a few issues I ran into following other peoples guides in the Android L Dicussions, so I thought I'll do a quick write on exactly what I did so you can go about building it for yourself.

A good resource on building CyanogenMod is available at http://wiki.cyanogenmod.org/w/Build_for_bacon, they don't have a guide for CM12, but still has some useful information.

Make sure you use the same operating system as I am using which is Ubuntu. I tried using Debian earlier, but had issues which may have been resulted to me not having enought memory on disk or me interupting the download of source code.

Preparing System for Build

Install the following items via apt-get.
Code:
sudo apt-get install bison build-essential curl flex git gnupg gperf 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 g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
As per the instructions on the wiki for building CM, if you use a 32bit system, do not install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev.

Install the latest version of Java's development kit using the following.
Code:
sudo apt-get install openjdk-7-jdk

Install the Android Development Kit using the following.
Code:
sudo apt-get install android androidsdk-uiautomatorviewer android-copyright android-src-vendor android-emulator android-tools-adb android-headers android-tools-adbd androidsdk-ddms  android-tools-fastboot androidsdk-hierarchyviewer android-tools-fsutils androidsdk-traceview

Run the following in terminal.
Code:
mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

reboot your system or use the following in terminal to load the .profile file again.
Code:
. ~/.profile

Getting the source code.

Now we can get onto grabbing the source code of CM12.
Run the following in terminal.
Code:
mkdir ~/cm
cd ~/cm
repo init -u git://github.com/CyanogenMod/android.git -b cm-12.0
mkdir .repo/local_manifests
nano .repo/local_manifests/local_manifests.xml

When nano appears, paste the following into it and then exit using ctrl-x and choose to save.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="CyanogenMod/android_device_oneplus_bacon" path="device/oneplus/bacon" remote="github" />
<project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" />
<project name="CyanogenMod/android_device_oppo_msm8974-common" path="device/oppo/msm8974-common" remote="github" />
<project name="CyanogenMod/android_device_oppo_common" path="device/oppo/common" remote="github" revision="cm-12.0" />
<project name="CyanogenMod/android_kernel_oneplus_msm8974" path="kernel/oneplus/msm8974" remote="github" />
<project name="TheMuppets/proprietary_vendor_oppo" path="vendor/oppo" remote="github" />
<project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" />
<project name="CyanogenMod/android_frameworks_opt_connectivity" path="frameworks/opt/connectivity" remote="github" revision="cm-11.0" />
</manifest>

Continue getting the code using the following.
Code:
repo sync
cd vendor/cm
./get-prebuilts
cd ../..

Building CM12
Run the following commands to build CyanogenMod.
Code:
. build/envsetup.sh
breakfast bacon
brunch bacon

After successful build, you should be able to go about copying the built CyanogenMod and installing it into your phone. The CyanogenMod build is located in ~/cm/out/target/product/bacon/ named something like cm-12-*-UNOFFICIAL-bacon.zip

You can install folllowing: http://forum.xda-developers.com/oneplus-one/general/lollipop-install-guide-oneplus-one-t2940091

Re-building to update.
To re-build, you should just be able to run the following (Not yet tested myself, but makes logical sense).
Code:
make clobber
repo sync
cd vendor/cm
./get-prebuilts
cd ../..
. build/envsetup.sh
brunch bacon

Q&A
Q: Recieve error: fatal: duplicate path device/qcom/sepolicy in ~/cm/.repo/manifest.xml
A: edit .repo/local_manifests/local_manifests.xml to remove the item which matches the item located in bold.

Q: How big is the repo?
A: 20GB just source code and 40GB when built. Therefore you should aim to have about 60GB free on your system.
 
Last edited:

pandasa123

Senior Member
Jul 20, 2013
1,562
1,534
South Grafton
you don't necessarily need Ubuntu 14.04. You could do just fine on 12.04 or 13.10 or whatever.

Also, something that's good to know: if you have a build environment that you've been building kitkat in, the only thing you need to do is update your Java from 1.6 to 1.7
 
  • Like
Reactions: grin0048

Quasar

Inactive Recognized Developer
Dec 3, 2013
2,296
3,202
Mumbai
Nice guide!

Umm.... As far as I know, it isn't necessary to croot...
And it seems to compile fine with just . build/envsetup.sh && brunch bacon.
Just my two cents. :)

Sent from my A0001 using XDA Premium 4 mobile app
 
Last edited:
  • Like
Reactions: scififone

Nburnes

Senior Member
Sep 4, 2010
1,330
977
Google Pixel 5a
Nice guide!

Umm.... As far as I know, it isn't necessary to croot...
And it seems to compile fine with just . build/envsetup.sh && brunch bacon.
Just my two cents. :)

Sent from my A0001 using XDA Premium 4 mobile app
Exactly this.
Croot "change root (directory)" is unneeded when you're already in the root directoy.

Code:
. build/envsetup.sh
breakfast bacon
brunch bacon
is more than than enough. This will automatically allocate to cores as is needed and compiles the flashable zips. Silly to make the build with make -j*of cores* and then make otapackage when one command will do both for you.

On the grounds of repo sync, inputting it just like that "repo sync" runs on 4 threads with -c already which is more than fast enough for people.

The CM manifests include a sensible default configuration for repo, which we strongly suggest you use (i.e. don't add any options to sync). For reference, our default values are -j 4 and -c. The -j 4 part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3 or -j 2. -c will ask repo to pull in only the current branch, instead of the entire CM history.


As for the platform tools, those are all installable through Ubuntu's apt repositories.
Code:
[email protected]:~$ sudo apt-get install android
android                       androidsdk-uiautomatorviewer
android-copyright             android-src-vendor
android-emulator              android-tools-adb
android-headers               android-tools-adbd
androidsdk-ddms               android-tools-fastboot
androidsdk-hierarchyviewer    android-tools-fsutils
androidsdk-traceview

No offense to @GRMrGecko but people should read up on what they're inputting into their Terminals.

What Envsetup does: http://wiki.cyanogenmod.org/w/Envsetup_help
 
  • Like
Reactions: TheDynamiteGuy

GRMrGecko

Senior Member
Dec 15, 2012
62
71
31
Huntsville
mrgecko.org
No offense to @GRMrGecko but people should read up on what they're inputting into their Terminals.

What Envsetup does: http://wiki.cyanogenmod.org/w/Envsetup_help

Thanks for the input. I had an understanding on what I was doing as far as envsetup.sh setting the environment for the commands for croot, breakfast, ect and that breakfast builds the make configuration somewhat like how configure on many other software. But I never took the time to go about and research as I wanted to make a working build and had issues using Debian. I thought that I will share what I did and just make a general resource for people to come to and get help with building as I only saw build instructions here and there in the Lollipop discussions.

I have incorporated your feedback into the instructions and I am testing the re-build now with your commands to verify that they work the way they are.

Thank you.
 
Last edited:
  • Like
Reactions: TheDynamiteGuy
D

Deleted member 2357893

Guest
I have this problem. How to solve it?

E: Unable to locate package android
E: Unable to locate package android-copyright
E: Unable to locate package android-src-vendor
E: Unable to locate package android-emulator
 
  • Like
Reactions: anthyava95

GRMrGecko

Senior Member
Dec 15, 2012
62
71
31
Huntsville
mrgecko.org
I have this problem. How to solve it?

E: Unable to locate package android
E: Unable to locate package android-copyright
E: Unable to locate package android-src-vendor
E: Unable to locate package android-emulator

What version of Ubuntu do you have? lsb_release -a

I think you may be fine with those packages not being available, as long as you get adb/fastboot.
 
  • Like
Reactions: anthyava95
D

Deleted member 2357893

Guest
What version of Ubuntu do you have? lsb_release -a

I think you may be fine with those packages not being available, as long as you get adb/fastboot.
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty
 
  • Like
Reactions: anthyava95

Top Liked Posts

  • There are no posts matching your filters.
  • 40
    Today I went about and built a copy of CM12 for my phone so that I can control when I get updates and I can get the most latest update. There was a few issues I ran into following other peoples guides in the Android L Dicussions, so I thought I'll do a quick write on exactly what I did so you can go about building it for yourself.

    A good resource on building CyanogenMod is available at http://wiki.cyanogenmod.org/w/Build_for_bacon, they don't have a guide for CM12, but still has some useful information.

    Make sure you use the same operating system as I am using which is Ubuntu. I tried using Debian earlier, but had issues which may have been resulted to me not having enought memory on disk or me interupting the download of source code.

    Preparing System for Build

    Install the following items via apt-get.
    Code:
    sudo apt-get install bison build-essential curl flex git gnupg gperf 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 g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
    As per the instructions on the wiki for building CM, if you use a 32bit system, do not install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev.

    Install the latest version of Java's development kit using the following.
    Code:
    sudo apt-get install openjdk-7-jdk

    Install the Android Development Kit using the following.
    Code:
    sudo apt-get install android androidsdk-uiautomatorviewer android-copyright android-src-vendor android-emulator android-tools-adb android-headers android-tools-adbd androidsdk-ddms  android-tools-fastboot androidsdk-hierarchyviewer android-tools-fsutils androidsdk-traceview

    Run the following in terminal.
    Code:
    mkdir -p ~/bin
    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo

    reboot your system or use the following in terminal to load the .profile file again.
    Code:
    . ~/.profile

    Getting the source code.

    Now we can get onto grabbing the source code of CM12.
    Run the following in terminal.
    Code:
    mkdir ~/cm
    cd ~/cm
    repo init -u git://github.com/CyanogenMod/android.git -b cm-12.0
    mkdir .repo/local_manifests
    nano .repo/local_manifests/local_manifests.xml

    When nano appears, paste the following into it and then exit using ctrl-x and choose to save.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <manifest>
    <project name="CyanogenMod/android_device_oneplus_bacon" path="device/oneplus/bacon" remote="github" />
    <project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" />
    <project name="CyanogenMod/android_device_oppo_msm8974-common" path="device/oppo/msm8974-common" remote="github" />
    <project name="CyanogenMod/android_device_oppo_common" path="device/oppo/common" remote="github" revision="cm-12.0" />
    <project name="CyanogenMod/android_kernel_oneplus_msm8974" path="kernel/oneplus/msm8974" remote="github" />
    <project name="TheMuppets/proprietary_vendor_oppo" path="vendor/oppo" remote="github" />
    <project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" />
    <project name="CyanogenMod/android_frameworks_opt_connectivity" path="frameworks/opt/connectivity" remote="github" revision="cm-11.0" />
    </manifest>

    Continue getting the code using the following.
    Code:
    repo sync
    cd vendor/cm
    ./get-prebuilts
    cd ../..

    Building CM12
    Run the following commands to build CyanogenMod.
    Code:
    . build/envsetup.sh
    breakfast bacon
    brunch bacon

    After successful build, you should be able to go about copying the built CyanogenMod and installing it into your phone. The CyanogenMod build is located in ~/cm/out/target/product/bacon/ named something like cm-12-*-UNOFFICIAL-bacon.zip

    You can install folllowing: http://forum.xda-developers.com/oneplus-one/general/lollipop-install-guide-oneplus-one-t2940091

    Re-building to update.
    To re-build, you should just be able to run the following (Not yet tested myself, but makes logical sense).
    Code:
    make clobber
    repo sync
    cd vendor/cm
    ./get-prebuilts
    cd ../..
    . build/envsetup.sh
    brunch bacon

    Q&A
    Q: Recieve error: fatal: duplicate path device/qcom/sepolicy in ~/cm/.repo/manifest.xml
    A: edit .repo/local_manifests/local_manifests.xml to remove the item which matches the item located in bold.

    Q: How big is the repo?
    A: 20GB just source code and 40GB when built. Therefore you should aim to have about 60GB free on your system.
    3
    Can someone assist me on how to go about making a self running script for the following commands from the OP so that I could run it and "walk away" from the computer? It would be nice to run it every evening at bedtime and then have an update waiting on me the next morning.

    make clobber
    repo sync -j1
    cd vendor/cm
    ./get-prebuilts
    cd ../..
    . build/envsetup.sh
    brunch bacon

    You can make a cronjob.

    nano ~/bin/makebacon
    Paste the following into the file.
    Code:
    #!/bin/bash
    cd ~/cm
    make clobber
    repo sync -j1
    cd vendor/cm
    ./get-prebuilts
    cd ../..
    . build/envsetup.sh
    brunch bacon

    run chmod +x ~/bin/makebacon

    With that, you can just type makebacon to build, or setup a cronjob by following http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/ the path to the script will be /home/USER/bin/makebacon

    Edit - another question: How did you retrieve this:
    <?xml version="1.0" encoding="UTF-8"?>
    <manifest>
    <project name="CyanogenMod/android_device_oneplus_bacon" path="device/oneplus/bacon" remote="github" />
    <project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" />
    <project name="CyanogenMod/android_device_oppo_msm8974-common" path="device/oppo/msm8974-common" remote="github" />
    <project name="CyanogenMod/android_device_oppo_common" path="device/oppo/common" remote="github" revision="cm-12.0" />
    <project name="CyanogenMod/android_kernel_oneplus_msm8974" path="kernel/oneplus/msm8974" remote="github" />
    <project name="TheMuppets/proprietary_vendor_oppo" path="vendor/oppo" remote="github" />
    <project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" />
    <project name="CyanogenMod/android_frameworks_opt_connectivity" path="frameworks/opt/connectivity" remote="github" revision="cm-11.0" />
    </manifest>

    From this page
    https://github.com/CyanogenMod/android_device_oneplus_bacon

    I saw people having success with building using that, so I just pulled it and used it. I don't know the original person who posted, but it was in http://forum.xda-developers.com/oneplus-one/general/android-l-discussions-rumors-talk-l-t2829974
    3
    Since yesterday the ./get-prebuilds is no longer working, some changes in the compiler? Although it's compiling fine :)
    They removed terminal emulator from the build so get-prebuilts is no longer needed.
    2
    If I understand correctly, after syncing source and building ROM, I would have exhausted 40GB of space ? OP says it is 20GB + 40 GB. My life hangs in a balance as I have 50GB overall free space. :)

    You'll run out of space building.
    2
    how big is the cm 12 download?

    20GB, probably larger once compiled.