Home » » Android Build Environment For Your Ubuntu Linux

Android Build Environment For Your Ubuntu Linux

Posted by Phone Trick on Sunday, May 3, 2015

Android Build Environment ubuntu set up


This Tutorial will discus how to set up Android Build Environment, we try to show you how to build Aosp or Cyanogen mod
for you Asus Zenfone 4,5 and 6,
 In this tutorial i will use Ubuntu 15.04 because in past few days i update my Ubuntu Linux to latest release so lets go..

Requirement

Ubuntu Linux 64 bit At least minimum of 4gb of ram
Java JDK
Android build tools
repo

 First we try to fix java version we will use note it always depend on android version we prepare to Build for android Kitkat version it required Java JDK 6 update 45 and for android Lollipop version need Java JDK 7 to latest update

 Open CLI Terminal in you Ubuntu box and follow this command
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*

 The above command will clean openjdk if you have before this will make sure will will be using the proper and needed java version for our android development build


For android kitkat build this is the Java version you need follow the command in you Terminal
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-java6-installer

follow the screen in you Terminal instructions, You must accept the License Agreement to complete the installation

For Android Lollipop Build This is The java version you need
follow the command in your Terminal
sudo apt-get update
sudo apt-get install openjdk-7-jdk

This below command bellow is Optional this command will help you to switch for your default Java version from java 6 to 7 or viversa
sudo update-alternatives --config java
sudo update-alternatives --config javac

f you encounter version errors for Java, set its path as described in the Wrong Java Version section.

java 7 for Lollipop
Java 6 for Gingerbread through KitKat

If you install Successfully the java jdk lets check the version if the target version build is properly install follow the command in your Terminal

java -version
Result:

java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Now lets install the the Builds Tools this is Require in order to build Android from source

 in terminal follow this command below
sudo apt-get install git gnupg ccache lzop libglapi-mesa-lts-utopic:i386 libgl1-mesa-dri-lts-utopic:i386 flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z1-dev libgl1-mesa-glx-lts-utopic:i386 libgl1-mesa-dev-lts-utopic g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev squashfs-tools pngcrush schedtool dpkg-dev

 After installation is done follow again this command in you terminal

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

 Now your done installing the required java version.

 Okay this time we need a program called REPO let you communicate with git server and download source code from git server

 now open new fresh terminal for the command below just follow the code
mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

 the above command will create a /bin folder on home directory of your Ubuntu Linux example /home/yourusername/bin

 Now we need to edit the .bashrc to add the bin path in our Ubuntu system to make life of android build easy yeah

 follow the command below
sudo gedit ~/.bashrc

 a new windows text editor will open and add the code below at the top of text editor at line 1

export PATH=~/bin:$PATH

 and then save and close

 Now where almost done will just need to download the android source code and build yeah now we need to find where we place the Android source code you can create new folder then open new terminal in that folder so lets go follow my command below

mkdir ~/zenfoneAOSP
cd ~/zenfoneAOSP

now we create a folder name zenfoneAOSP and the location is /Home/yourusername/zenfoneAOSP

Here the link for manifest if you want to check in Android Google source
https://android.googlesource.com/platform/manifest/+refs

now lets continue in our terminal that which locate on zenfoneAOSP folder follow the command below

For AOSP kitkat if you need to build in higher version check the link bellow for Aosp source branch

Here the link for manifest if you want to check in Android Google source
https://android.googlesource.com/platform/manifest/+refs
repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.4_r2

For Cyanogen mod 11
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0 -j4

for Cyanogen mod 12

repo init -u git://github.com/CyanogenMod/android.git -b cm-12.0 -j4

Lets explain above code

repo init -u url option

Installs Repo in the current directory. This creates a .repo/ directory that contains Git repositories for the Repo source code and the standard Android manifest files. The .repo/ directory also contains manifest.xml, which is a system link to the selected manifest in the .repo/manifests/ director

-b android-4.4.4_r2

And follow this final command to sync repo

repo sync -j4

 is number of connection to download it continuously if you use -j4 it will download 4 parts at a time so sound good this is better if you have Good Internet connection you can adjust to -8 or -j16 , i advise if you have slow Internet you can use -j1 or -j2 the android Sources size is 20 plus GB so it take time if your Internet is not that good as other actually in my case i download the source almost 1 week before i complete download the source because of my poor Internet connection, so if you realy interested to learn to build from source you may need patient Thank i hope you learn How to Set up Android Build Environment for you Ubuntu Linux so in Other day we can now forward in new topic for building aosp for Asus Zenfone or Cyanogen mod


0 comments:

Post a Comment

Blog Archive

Powered by Blogger.
.comment-content a {display: none;}