FORUMS
Remove All Ads from XDA

[Tutorial] Compile Lollipop on Ubuntu

3,849 posts
Thanks Meter: 10,651
 
Post Reply Email Thread
NOTICE: I'm fine with this tutorial being posted on other sites, as long as I am given credit and have your thread point back to here for the pieces that I have specifically written. I do not condone near verbatim or verbatim copy and pasting of my work or others work without credit. Please give credit where credit is due. Thank you.

07-17-12: I have not, nor shall I ever claim copyright.


To compile Lollipop on Ubuntu I'm going to first give you steps to set up your computer to get this thing rolling.

You MUST be running a 64 bit version of Ubuntu, 32 bit is not supported.

This will NOT make a fully functional ROM, but will give you a place to start. Also I CANNOT fix every error you run into.

READ the entire OP and make sure to properly follow instructions. Don't forget to search the thread as your question may have already been answered.

Please use Pastebin for all errors you run into. Posting a link is much easier than a long list of errors in the thread. Thank you.

Source is roughly 8.5GB in size and you will need over 30GB (or more) free to complete a single build, and up to 100GB (or more) for a full set of builds.

1) You need the following:
-JDK 7 if you wish to build Lollipop.
Code:
$ sudo apt-get update
$ sudo apt-get install openjdk-7-jdk
Optionally, update the default Java version by running:
Code:
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
If you encounter version errors for Java, then it could be:
  • Failing to install the correct JDK
  • Another JDK previously installed appearing in your path. Prepend the correct JDK to the beginning of your PATH or remove the problematic JDK

-Python, which you can download from python.org. Or:
Code:
$ sudo apt-get install python
-Git, which you can find it at git-scm.com. Or:
Code:
$ sudo apt-get install git-core
-Android SDK:
  • 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) Installing required packages (Ubuntu 13.04+)
Code:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev lib32z1 \
  lib32ncurses5 lib32bz2-1.0 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 \
  lib32z1-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos \
  python-markdown libxml2-utils xsltproc readline-common libreadline6-dev libreadline6 \
  lib32readline-gplv2-dev libncurses5-dev lib32readline5 lib32readline6 libreadline-dev \
  libreadline6-dev:i386 libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev \
  lib32bz2-dev libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev python lzop
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Installing required packages (Ubuntu 12.04)
Code:
$ sudo apt-get install git 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 tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Installing required packages (Ubuntu 10.04 -- 11.10)
Code:
$ sudo apt-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 \
  libxml2-utils xsltproc
On Ubuntu 10.10:
Code:
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
On Ubuntu 11.10:
Code:
$ sudo apt-get install libx11-dev:i386
3) Configure your USB.
Code:
$ gksudo gedit /etc/udev/rules.d/51-android.rules
Inside of this blank text file insert:
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"
4) Save the file and close it and then issue this command:
Code:
$ sudo chmod a+r /etc/udev/rules.d/51-android.rules
4a) [OPTIONAL] Setting up 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.

Code:
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.

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

Code:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
This setting is stored in the CCACHE_DIR and is persistent.

5) Install the repo:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
6) Initialize the repo:
Code:
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
6a) For AOSP:
Code:
$ repo init -u https://android.googlesource.com/platform/manifest.git -b android-5.1.1_r13
6.1) For people who have already done a repo init:
Code:
$ cd WORKING_DIRECTORY
AOSP:
Code:
$ repo init -b android-5.1.1_r13
$ repo sync
7) When prompted, enter your real name and email address.

8) Gather the files:
Code:
$ repo sync
9) Continue onto adding a device

~How To Add A Device To The List~

1) Find the github for your device you wish to add. (For me it is the Asus Nexus 7 (2013) [codename: flo]

2) Now navigate to the location you are going clone the device tree to:
Code:
$ cd WORKING_DIRECTORY/device
$ mkdir asus
3) Clone the github device tree from remote to local: (The name after the branch would be whatever you want that folder to be named so make sure it is whatever standard name would be for your device, example: Nexus One [passion], Nexus S [crespo], Motorola Droid [sholes], HTC Incredible [inc], etc.)
Code:
$ git clone https://android.googlesource.com/device/asus/flo.git -b lollipop-dev flo
4) Now navigate into the folder:
Code:
$ cd flo
5) Connect phone to computer and make sure USB debugging is enabled and you have adb set up.

6) Extract Device Proprietary Files (if extract script is present):
Code:
$ ./extract-files.sh
Or:
Code:
./proprietary-files.sh
Or: See use your device's provided proprietary blobs (like flo): Download the binaries from: https://developers.google.com/android/nexus/drivers
Extract the blobs and place them in the directory from the root of your working directory (ex. vendor/asus/flo): vendor/MANUFACTUROR/CODENAME

7) Navigate back to your home directory for building:
Code:
$ cd ~/WORKING_DIRECTORY
8) Prepare To Compile:
Code:
$ source build/envsetup.sh
Or:
Code:
$ . build/envsetup.sh
9) Get your list of devices:
Code:
$ lunch
10) Pick your poison.

11) Now compile ('#' being the number of cores in your processor +1):
Code:
$ make -j#
Or for a flashable zip:
Code:
$ make -j# otapackage
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This tutorial is based off this one: http://source.android.com/source/initializing.html
The Following 26 Users Say Thank You to dastin1015 For This Useful Post: [ View ] Gift dastin1015 Ad-Free
 
 
6th November 2014, 10:54 AM |#2  
F-L-Y-E-R's Avatar
Senior Member
Flag London
Thanks Meter: 1,299
 
Donate to Me
More
Question
Is this tutorial only for officially supported devices that are/will be running 'lollipop'? Will I be able to build lollipop on other device from this source? The thing is that I need to encode the device so it is compatible with 'lollipop'. I'm not really sure how it's done but if it's possible can you explain how or direct me in the right direction? Thanks.
8th November 2014, 12:31 AM |#3  
Senior Member
Flag chandigarh
Thanks Meter: 98
 
More
Very nice guide.

Please I need serious help

I am trying to build lollipop for oneplus one.
I have followed multiple guides to get this correct.

However I am stuck at navendu@navendu:~/bin/WORKING_DIRECTORY$ make -j16
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.0
TARGET_PRODUCT=aosp_bacon
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=krait
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-25-generic-x86_64-with-Ubuntu-14.10-utopic
HOST_BUILD_TYPE=release
BUILD_ID=LRX21M
OUT_DIR=out
============================================
Checking build tools versions...
build/core/dex_preopt.mk:47: *** target pattern contains no '%'. Stop.


However if i use "sudo make -j 16"
I get this
Which would you like? [aosp_arm-eng] 15

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.0
TARGET_PRODUCT=aosp_bacon
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=krait
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-25-generic-x86_64-with-Ubuntu-14.10-utopic
HOST_BUILD_TYPE=release
BUILD_ID=LRX21M
OUT_DIR=out
============================================

navendu@navendu:~/bin/WORKING_DIRECTORY$ sudo make -j16
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.0
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-25-generic-x86_64-with-Ubuntu-14.10-utopic
HOST_BUILD_TYPE=release
BUILD_ID=LRX21M
OUT_DIR=out
============================================
Checking build tools versions...

What happens is the target product and everything changes so the output is a generic build.

Please help

Thanks
The Following User Says Thank You to navendugoyal For This Useful Post: [ View ] Gift navendugoyal Ad-Free
8th November 2014, 01:18 AM |#4  
GROGG88's Avatar
Recognized Contributor
Flag Lone Star State
Thanks Meter: 3,040
 
Donate to Me
More
Quote:
Originally Posted by navendugoyal

Very nice guide.

Please I need serious help

I am trying to build lollipop for oneplus one.

You have to have a device tree for your product. You must then select that device and build type using 'lunch'.
The Following User Says Thank You to GROGG88 For This Useful Post: [ View ] Gift GROGG88 Ad-Free
8th November 2014, 01:29 AM |#5  
Senior Member
Flag chandigarh
Thanks Meter: 98
 
More
Device tree is there
Quote:
Originally Posted by GROGG88

You have to have a device tree for your product. You must then select that device and build type using 'lunch'.

Thanks for replying buddy, highly appreciate it.
Device tree is present.

Infact I have tried multiple device tree setups - but get the same error everytime
I have tried
CM
Oneplusaosp
TheUnas

but the same error
Also why after the sudo make command it should be changing the target product to a generic ?
8th November 2014, 01:36 AM |#6  
Senior Member
Flag chandigarh
Thanks Meter: 98
 
More
screenshots - device tree
here is the device tree screenshot
Attached Thumbnails
Click image for larger version

Name:	device-tree.jpg
Views:	1828
Size:	91.3 KB
ID:	3004585  
8th November 2014, 02:05 AM |#7  
GROGG88's Avatar
Recognized Contributor
Flag Lone Star State
Thanks Meter: 3,040
 
Donate to Me
More
Quote:
Originally Posted by navendugoyal

Thanks for replying buddy, highly appreciate it.
Device tree is present.

Infact I have tried multiple device tree setups - but get the same error everytime
I have tried
CM
Oneplusaosp
TheUnas

but the same error
Also why after the sudo make command it should be changing the target product to a generic ?

I do not have a solid answer regarding why 'sudo' would change your target. That truly is odd, but at the same time there is no reason why you should need sudo since your build did not fail due to permissions.

I'm curious... Where exactly did you fetch your device tree from? I do not see it in googlesource.com. Seeing as you're building for the OnePlusOne, I must ask if you're attempting to build AOSP or CM?
8th November 2014, 02:26 AM |#8  
Senior Member
Flag chandigarh
Thanks Meter: 98
 
More
Quote:
Originally Posted by GROGG88

I do not have a solid answer regarding why 'sudo' would change your target. That truly is odd, but at the same time there is no reason why you should need sudo since your build did not fail due to permissions.

I'm curious... Where exactly did you fetch your device tree from? I do not see it in googlesource.com. Seeing as you're building for the OnePlusOne, I must ask if you're attempting to build AOSP or CM?

Here are the 2 places I have tried my device tree form
https://github.com/OnePlusAosp/andro...plus_bacon.git

Also
https://github.com/TheUnas - they have forked lot of things for OneplusOne lollipop.
The Following User Says Thank You to navendugoyal For This Useful Post: [ View ] Gift navendugoyal Ad-Free
8th November 2014, 02:42 AM |#9  
Senior Member
Thanks Meter: 42
 
More
great guide i'am doing mt first build fingures crossed it works thanks again buddy
8th November 2014, 02:49 AM |#10  
GROGG88's Avatar
Recognized Contributor
Flag Lone Star State
Thanks Meter: 3,040
 
Donate to Me
More
Quote:
Originally Posted by navendugoyal

Here are the 2 places I have tried my device tree form
https://github.com/OnePlusAosp/andro...plus_bacon.git

Also
https://github.com/TheUnas - they have forked lot of things for OneplusOne lollipop.

Do you have a copy of '../device/oppo/common/common.mk' ?

I'm trying to duplicate your condition against my source, but I need to know exactly what you've added to your tree. So far I'm coming up with this:
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2014-11-07 19:44:58.jpg
Views:	844
Size:	162.4 KB
ID:	3004642  
8th November 2014, 02:56 AM |#11  
Senior Member
Flag chandigarh
Thanks Meter: 98
 
More
Quote:
Originally Posted by GROGG88

Do you have a copy of '../device/oppo/common/common.mk' ?

I'm trying to duplicate your condition against my source, but I need to know exactly what you've added to your tree. So far I'm coming up with this:

Yes I have
See the screenshot

You can get them from here
https://github.com/TheUnas
Attached Thumbnails
Click image for larger version

Name:	device-oppo.png
Views:	518
Size:	37.2 KB
ID:	3004647   Click image for larger version

Name:	device-oppo2.png
Views:	498
Size:	56.7 KB
ID:	3004648  
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