[HOW-TO]Android source compiling on Ubuntu All variants - Build from Source
First of all, let me clear myself what I am describing here is a simplified version is what Google provided in their Building Android from Source, So I am not taking any copyright issue or anything you are going to do with this guide. U can use this guide and make a ROM. And if you think it's worthwhile to give credit to this thread, give link to this thread. I don't mind if you don't give credit to this thread, atleast you are making better android development.
What is this thread for?
- This is the thread which will guide you about how to setup environment for building an android from source. Feel free to ask question regarding it. You also can copy paste your error (if it’s short) or attach log cat (weather in .text file or from pastebin). I will try to solve any many errors as I can, but come on I CANNOT solve every errors you ran into.
- Though this thread is noob friendly, for sure you require basic computer knowledge especially regarding Ubuntu setup and basic command prompt.
- You should have install Ubuntu 64-bit version (32-bit version is not supported) to your computer either in virtual machine or as separate Operating System.
- For Ubuntu you require minimum 80 GB of space to compile a single build from source.
- I think I made myself clear about requirements.
- This might not build fully working ROM and you may have to do some changes according to it.
I am not responsible for any broken PCs or damaged hard drive or anything unexpected and unfortunate happen to your computer or to your device. You are doing everything by knowing all the risks, so don’t blame on me about anything.
INDEX of Topics I am describing here
Post – 1: Setting up build environment
Post – 2: Install and Initialise repo
Post – 3: Setup device for specific build
Post – 4: Device specific vendor changes
Post - 5: Repo optimization and speed up build environment
Post – 6: reserve for future use
Post – 7: reserve for future use.
Now, Let’s start with real stuff …..
1A. Install JDK 6
sudo apt-get install openjdk-6-jdk
1B. Install python
sudo apt-get install python
1C. Install git-core
sudo apt-get install git-core
1D. Install android SDK
- Download it: http://developer.android.com/sdk/index.html
- Extract it to your home directory and rename it to android-sdk
- At home press ctrl+h to see hidden files and folder
- Open .bashrc file with text editor
- Add following lines at the end of it
2D: When prompted, enter your real name and email address.
2E: Sync Repo from remote to local
This will take times as it will download all source from github to your computer it depend on your internet connection that how long it will take from anywhere around 30 minutes(If you have 4 mbps download speed) to 30 days(If you have 30kbps download speed).
So, now you will have to add device tree and dependencies to local repo...
For that you have to copy sources from github to local directory and also device's repository
Let's start with it... (I am describing here how to setup device tree for cm10.1 from CMX10 repositories)
3A: Add Device tree and dependency for cm10.1
- Go to your working directory and press ctrl+h - You will see .repo directory
- Open .repo and there make a folder named local_manifests
- In .repo/local_manifests right click and make a new document and name it to roomservice.xml and type this :
- All vendor setup will be made to the local directory in your WORKING_DIRECTORY/Vendor
4A: Slimroms Vendor Setup
- Go to vendor/slim to your local directory
- Here you only need to edit one file and that file is vendorsetup.sh
- Open vendorsetup.sh with text editor and just add this line to the end of the file
- Save file and you are ready to go with Step 3F
4B: Vendor Setup for MoKee OpenSource
- Go to vendor/mk to your local directory
- Here you have to edit 1 file and that file is mokee-build-targets
- Open mokee-build-targets with text editor and just add this line to the end of the file
- Save file and you are ready to go with Step 3F
4C: Vendor Setup For Paranoid Android
- Go to vendor/pa to your local directory
- Here you need to edit files in packages, Products, vendorprops and vendorsetup.sh
So, First we are going to add file in vendor/pa/packages, so go to vendor/pa/packages
- Here we are adding torch to our package
- Right click and create a blank document and name it as es209ra.mk and copy paste this content.
# Extra packages
PRODUCT_PACKAGES += \
Now go to vendor/pa/products
- Here we have to add product file for our device
- Open AndroidProducts.mk file with text editor and following lines at the end
- Right click and create a blank document and name it as pa_es209ra.mk
- Copy Paste following details in that file
# Copyright (C) 2012 ParanoidAndroid Project
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Check for target product
# Define PA bootanimation size
PARANOID_BOOTANIMATION_NAME := HDPI
# OVERLAY_TARGET adds overlay asset source
OVERLAY_TARGET := pa_hdpi
# Build paprefs from sources
PREFS_FROM_SOURCE ?= false
# Include ParanoidAndroid common configuration
# Inherit AOSP device configuration
$(call inherit-product, device/semc/es209ra/full_es209ra.mk)
# Product Package Extras
# Override AOSP build properties
PRODUCT_NAME := pa_es209ra
PRODUCT_BRAND := semc
PRODUCT_MODEL := es209ra
PRODUCT_MANUFACTURER := Sony Ericsson
PRODUCT_BUILD_PROP_OVERRIDES += PRODUCT_NAME=LT18i BUILD_FINGERPRINT="SEMC/LT18i_1254-2184/LT18i:4.0.4/4.1.B.0.431/UL5_3w:user/release-keys" PRIVATE_BUILD_DESC="LT18i-user 4.0.4 4.1.B.0.431 UL5_3w test-keys"
# Update local_manifest.xml
GET_VENDOR_PROPS := $(shell vendor/pa/tools/getvendorprops.py $(PRODUCT_NAME))
GET_PROJECT_RMS := $(shell vendor/pa/tools/removeprojects.py $(PRODUCT_NAME))
GET_PROJECT_ADDS := $(shell vendor/pa/tools/addprojects.py $(PRODUCT_NAME))
- Edit vendosetup.sh file
- Go to vendor/pa and vendorsetup.sh with text editor
- Copy Paste followinfg lines at the end of that file
- Now you are ready to go with step 3F
4D: Vendor Setup For PAC-Man
- Here we have to edit files in vendor/pac
- We have to edit files of products and vendorsetup.sh
- Go to vendor/pac/products
- Right click and create blank document and name it as pac_es209ra.mk
- Copy paste following content to that file
While we are all wondering when Google will decide to officially release … more
19 Aug 2014
By Tomek Kondrat
XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality. Are you a developer?