Skip to main content

How to Build Android Lollipop in Ubuntu 14.04?

How to build Android Lollipop in Ubuntu 14.04?

How to build Android Lollipop in Ubuntu 14.04?

image.png

Introduction

There is a way that help you to build Android Lollipop (Android 5.0, API 21). We will arrange some script shell to help you after development. I hope everyone that enjoys to quickly comfortable development environment.

Equipment

Operation System: Ubuntu 14.04 LTS

Usage

  1. To Install the necessary libraries and tools for Ubuntu 14.04 LTS.


# su   
Password:   
$ 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 apt-get install bison g++-multilib git gperf libxml2-utils   
(… More)   


  1. The Android in the Android Open Source Project (AOSP) requires Java 7. On Ubuntu, use OpenJDK.

2.1. Generally, The tool (update-alternatives) has been installed your Linux system. It is a very usefully tool and it is able to help you easily switch to different compilers. Of course, you need to make sure you have the tool.



$ sudo update-alternatives --version
Debian update-alternatives version 1.16.15.

This is free software; see the GNU General Public License version 2 or later for copying conditions. There is NO warranty.

2.2. Moreover, you have tried to install more than one compilers. For example, you will install various kinds of the compilers, such as gcc, g++, Java, Open JDK, etc.



$ sudo apt-get install gcc-4.4 gcc-4.6 gcc-4.7 gcc-4.8 g++-4.4 g++-4.6 g++-4.7 g++-4.8


2.3. Nonetheless, just only one can be a symbolic link. Let me explain more detail about how to set up the tool. Now, you will install symbol links for those compilers respectively.

2.4. Installation a symbolic link.
In this case, you can follow the format of parameters as below. Format: sudo (change to be a root) update-alternatives (the tool name) –install (To make up a symbolic link) /usr/bin/gcc (your gcc symbol link) gcc (a configuration name) /usr/bin/gcc-4.4 (your gcc installation path) 1 (priority)



$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 1
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 4
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 5
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 2


2.5. The choice you want to a compiler to be default.



$ sudo update-alternatives --config gcc


There are 4 choices for the alternative gcc (providing /usr/bin/gcc).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/gcc-4.7 5 auto mode
1 /usr/bin/gcc-4.4 1 manual mode
2 /usr/bin/gcc-4.6 4 manual mode
3 /usr/bin/gcc-4.7 5 manual mode
* 4 /usr/bin/gcc-4.8 2 manual mode

Press enter to keep the current choice[*], or type selection number:

2.6. Notwithstanding the initial confusion, the tool (update-alternatives) was a success. I think you should spend a few times doing this, because you will be to earn more time to develop.



$ sudo update-alternatives --config java


There are 8 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
3 /usr/lib/jvm/jdk1.6.0_37-i586/bin/java 1 manual mode
4 /usr/lib/jvm/jdk1.6.0_37-x64/bin/java 2 manual mode
5 /usr/lib/jvm/jdk1.6.0_45-i586/bin/java 3 manual mode
6 /usr/lib/jvm/jdk1.6.0_45-x64/bin/java 4 manual mode
7 /usr/lib/jvm/jdk1.7.0_67-i586/bin/java 5 manual mode
8 /usr/lib/jvm/jdk1.7.0_67-x64/bin/java 6 manual mode

Press enter to keep the current choice[*], or type selection number:



$ sudo update-alternatives --config javac


There are 8 choices for the alternative javac (providing /usr/bin/javac).

Selection Path Priority Status
------------------------------------------------------------

0 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1071 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1071 manual mode
3 /usr/lib/jvm/jdk1.6.0_37-i586/bin/javac 1 manual mode
4 /usr/lib/jvm/jdk1.6.0_37-x64/bin/javac 2 manual mode
5 /usr/lib/jvm/jdk1.6.0_45-i586/bin/javac 3 manual mode
6 /usr/lib/jvm/jdk1.6.0_45-x64/bin/javac 4 manual mode
7 /usr/lib/jvm/jdk1.7.0_67-i586/bin/javac 5 manual mode
8 /usr/lib/jvm/jdk1.7.0_67-x64/bin/javac 6 manual mode

Press enter to keep the current choice[*], or type selection number:



$ sudo update-alternatives --config javaws


There are 8 choices for the alternative javaws (providing /usr/bin/javaws).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws 1071 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws 1071 manual mode
3 /usr/lib/jvm/jdk1.6.0_37-i586/bin/javaws 1 manual mode
4 /usr/lib/jvm/jdk1.6.0_37-x64/bin/javaws 2 manual mode
5 /usr/lib/jvm/jdk1.6.0_45-i586/bin/javaws 3 manual mode
6 /usr/lib/jvm/jdk1.6.0_45-x64/bin/javaws 4 manual mode
7 /usr/lib/jvm/jdk1.7.0_67-i586/bin/javaws 5 manual mode
8 /usr/lib/jvm/jdk1.7.0_67-x64/bin/javaws 6 manual mode

Press enter to keep the current choice[*], or type selection number:



$ sudo update-alternatives --config gcc


There are 4 choices for the alternative gcc (providing /usr/bin/gcc).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/gcc-4.7 5 auto mode
1 /usr/bin/gcc-4.4 1 manual mode
2 /usr/bin/gcc-4.6 4 manual mode
3 /usr/bin/gcc-4.7 5 manual mode
* 4 /usr/bin/gcc-4.8 2 manual mode

Press enter to keep the current choice[*], or type selection number:



$ sudo update-alternatives --config g++


There are 4 choices for the alternative g++ (providing /usr/bin/g++).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/g++-4.7 5 auto mode
1 /usr/bin/g++-4.4 1 manual mode
2 /usr/bin/g++-4.6 4 manual mode
3 /usr/bin/g++-4.7 5 manual mode
* 4 /usr/bin/g++-4.8 2 manual mode

Press enter to keep the current choice[*], or type selection number:

3.. Installing Repo
Repo is a tool that makes it easier to work with Git in the context of Android.
Make sure you have a bin/ directory in your home directory and that it is included in your path:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
Download the Repo tool and ensure that it is executable:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

3.1. Initializing a Repo client and download it.
After installing Repo, set up your client to access the Android source repository:
Create an empty directory to hold your working files.

$ mkdir (your working directory)
$ cd (your working directory)
Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.
$ repo init -u https://android.googlesource.com/platform/manifest
$ repo sync

This may take a long time, take a break. To wait it to download finished.

4.. To install the python switch tool.

4.1. If you haven't used GIT, you should install it before you get started.
$ sudo apt-get install curl git-core

4.2. For automatically install pyenv.
$ curl https://raw.github.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

4.3. Open up .bashrc located in your home directory with a text editor and add the following.
File Name: .bashrc
# Python environment switch
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
(Save it)

$ source ~/.bashrc

4.4. To Verify pyenv is installed properly
$ pyenv --version
pyenv 20140924-1-g737e0f1

4.5. List of Python versions.
$ pyenv install –list
Available versions: 2.1.3 2.2.3 2.3.7 2.4 2.4.1 (… More)

4.6. To install a python version.
$ pyenv install 3.3.4 -v
/tmp/python-build.20150111112656.5021 ~
Downloading Python-3.3.4.tgz...
HTTP/1.1 200 OK
Server: GitHub.com
Content-Type: application/octet-stream
Last-Modified: Tue, 04 Nov 2014 09:32:24 GMT
Expires: Sun, 11 Jan 2015 03:36:56 GMT
Cache-Control: max-age=600
Content-Length: 16843278
Accept-Ranges: bytes
Date: Sun, 11 Jan 2015 03:27:01 GMT
Via: 1.1 varnish
Age: 5
Connection: keep-alive
X-Served-By: cache-ty67-TYO
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1420946816.328055,VS0,VE4793
Vary: Accept-Encoding
-> http://yyuu.github.io/pythons/ea055db9dd004a6ecd7690abc9734573763686dd768122316bae2dfd026412af
(… More)

4.7. To list python versions.
$ pyenv versions
* system (set by /home/brianlai/.python-version)
2.6.6
3.3.4
4.8. To switch another python version.
$ export PYENV_VERSION=3.3.4
$ pyenv versions
system
2.6.6
* 3.3.4 (set by PYENV_VERSION environment variable)
$ export PYENV_VERSION=system
$ pyenv versions
* system (set by PYENV_VERSION environment variable)
2.6.6
3.3.4

5.. To write a bash shell scription.
File Name: build-android-L.sh
#!/bin/bash
root_path=`pwd`
cd $root_path/(your working directory)/
# gcc 4.8
sudo update-alternatives --set gcc /usr/bin/gcc-4.8
sudo update-alternatives --set g++ /usr/bin/g++-4.8
# OpenJava 1.7.0_amd64
sudo update-alternatives --set java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-7-openjdk-amd64/bin/javac
sudo update-alternatives --set javaws /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws
# python 2.7.6
pyenv local system
# Android
source build/envsetup.sh
lunch
# make 3.81
make -j8
(Save it)

6.. To additional export parameter into the bash shell environment.

File Name: .bashrc
export ARCH=arm
export SUBARCH=arm
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
export PATH=~/bin:$PATH
export PATH=/(your ARM tool chain path)/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
export CROSS_COMPILE=arm-eabi-
(Save it)

7.. To build your Android Lollipop by bash shell scription.
$ bash build-android-L.sh

Exception

1.. If your operation system is not Ubuntu 14.04 LTS, Please, refer to as below.

On Ubuntu 10.10:
$ 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
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
On Ubuntu 11.10:
$ 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
$ sudo apt-get install libx11-dev:i386
On Ubuntu 12.04 (64 bit)
$ 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

2.. To check out a branch other than "master", specify it with -b:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-5.0.2_r1

Reference

[1] http://source.android.com/source/build-numbers.html
[2] http://source.android.com/source/initializing.html
[3] http://source.android.com/source/downloading.html
[4] http://source.android.com/source/building-running.html

Acknowledge

Thank you (Google, Android, OpenJDK, Python, GNU) very much for this great development utility.

Popular Posts

波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

最佳化處理策略之快速消除扭曲演算法

Visual Basic 6.0 程式案例學習: 10. 條碼列印程式 (2014版)

波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Image

最佳化處理策略之快速消除扭曲演算法

Image

Visual Basic 6.0 程式案例學習: 10. 條碼列印程式 (2014版)

Image

Python 日期與時間的處理

Image

Visual Basic .Net 程式案例學習: 06. 題庫測驗系統 (2014版)

Image

用10種程式語言做影像二值化(Image binarization)

Image

修復損毀的 SQLite DB 資料庫

Image

解決 ValueError: If using all scalar values, you must pass an index

Image

Visual Basic 6.0 程式案例學習: 04. 人事考勤管理系統 (2014版)

Image

Visual Basic 6.0 程式案例學習: 07. 收據列印程式 (2014版)

Image

佑佑的 Line 貼圖創作

貼圖作者網址:

https://line.me/S/shop/sticker/author/3883362

靜態貼圖

 
 
 
 
  牡羊座:狗狗角色

作者:佑佑
依照牡羊座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  金牛座:兔兔角色

作者:佑佑
依照金牛座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  雙子座:貓貓角色

作者:佑佑
依照雙子座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  巨蟹座:倉鼠角色

作者:佑佑
依照巨蟹座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  獅子座:幼獅角色

作者:佑佑
依照獅子座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  處女座:松鼠角色

作者:佑佑
依照處女座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  天秤座:鴿子角色

作者:佑佑
依照天秤座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  天蠍座:鳳凰角色

作者:佑佑
依照天蠍座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  射手座:人馬角色

作者:佑佑
依照射手座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  魔羯座:山羊角色

作者:佑佑
依照魔羯座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  水瓶座:海豚角色

作者:佑佑
依照水瓶座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  雙魚座:小丑魚角色

作者:佑佑
依照雙魚座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  上班族都變成狒狒,心裡想要說的話。

作者:佑佑
最近在台灣走紅的狒狒,用擬人化的方式,變成上班族,畫出心裡的想說的話。
購買貼圖
  接案派遣的日常

作者:佑佑
接案派遣到其他公司的日常對話,有調皮、正經、日常對話。
購買貼圖
  貓女事務員的搞笑時刻

作者:佑佑
把行政人員在職場上遇到千奇百怪的事情畫出來,用可愛的貓女來擔任行政人員的代言人。
購買貼圖
  貓貓說每天都會用到的話

作者:佑佑
日常生活常見的短句,用小貓擬人化的方式呈現,比較親切可愛。
購買貼圖
 
     
  大人的煩惱特輯:小兔角色

作者:佑佑
錢包餓了,生活苦了。變美變健康?先讓我睡飽吧。心好累,我需要充電。
購買貼圖
     

動態貼圖

 
 
 
 
  牡羊座日常交際:狗狗角色

作者:佑佑
依照牡羊座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  金牛座日常交際:兔兔角色

作者:佑佑
依照金牛座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  雙子座日常交際:貓貓角色

作者:佑佑
依照雙子座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  巨蟹座日常交際:倉鼠角色

作者:佑佑
依照巨蟹座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  獅子座日常交際:幼獅角色

作者:佑佑
依照獅子座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  處女座日常交際:松鼠角色

作者:佑佑
依照處女座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  天秤座日常交際:鴿子角色

作者:佑佑
依照天秤座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  天蠍座日常交際:鳳凰角色

作者:佑佑
依照天蠍座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  射手座日常交際:人馬角色

作者:佑佑
依照射手座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  魔羯座日常交際:山羊角色

作者:佑佑
依照魔羯座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  水瓶座日常交際:海豚角色

作者:佑佑
依照水瓶座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  雙魚座日常交際:小丑魚角色

作者:佑佑
依照雙魚座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
     
  厭世報:鬍渣男

作者:佑佑
厭世總有個理由跟原因,實在是令人不爽,為什麼最倒楣的總是我?真希望明天就是世界末日,讓大家都一樣慘。
購買貼圖
     

表情貼

 
 
 
 
  貓貓說每天都用得到的表情貼

作者:佑佑
日常生活常見的表情用語,用小貓擬人化的方式呈現,比較親切可愛。
購買貼圖
  天秤座的表情貼:鴿子角色

作者:佑佑
日常生活常見的表情用語,天秤座的鴿子擬人化方式呈現,比較親切可愛。
購買貼圖
  天蠍座的表情貼:鳳凰角色

作者:佑佑
日常生活常見的表情用語,天蠍座的鳳凰擬人化方式呈現,比較親切可愛。
購買貼圖
  射手座的表情貼:人馬角色

作者:佑佑
日常生活常見的表情用語,射手座的人馬擬人化方式呈現,比較親切可愛。
購買貼圖
 
 
 
 
  魔羯座的表情貼:山羊角色

作者:佑佑
日常生活常見的表情用語,魔羯座的山羊擬人化方式呈現,比較親切可愛。
購買貼圖
  水瓶座的表情貼:海豚角色

作者:佑佑
日常生活常見的表情用語,水瓶座的海豚擬人化方式呈現,比較親切可愛。
購買貼圖
  雙魚座的表情貼:小丑魚角色

作者:佑佑
日常生活常見的表情用語,雙魚座的小丑魚擬人化方式呈現,比較親切可愛。
購買貼圖