ARCHIVE - Please follow [[https://wiki.linaro.org/Platform/Android/GetSource#preview|GetSource page]]

Build instructions verified on Ubuntu-10.04, Ubuntu 10.10 and Mandriva Cooker HOST machines.

See also ReproduceABuildExactly if you want to reproduce one of the builds available at https://android-build.linaro.org/ (the instructions below describe how to build the tip of active Linaro branch).

Help!

If Something Goes Wrong or You Have Quesitons

Setting up a Build Environment

Make sure you go through this checklist first: http://source.android.com/source/initializing.html

On Ubuntu

  • The instructions at above link have been summarized here:
  • 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 lib32z-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils uuid-dev libgl1-mesa-dev
  • For 32bit systems (Ubuntu 11.10 and later)
  • sudo apt-get install lib32readline-gplv2-dev
    
    # 11.10 has an issue with libncurses and libtinfo. You'll need to run this command as root:
    cd /lib32; ln -s libtinfo.so.5 libtinfo.so 
  • For 32bit systems (Ubuntu 10.10 and older)
  • sudo apt-get install lib32readline5-dev
  • Install Java and Ant
  • sudo apt-get install openjdk-6-jdk ant
  • Install Linaro tools
  • sudo apt-get install linaro-image-tools
  • This should cover most of the required packages. This list is usually in flux and undergoes changes. If a package is missing please look in the setup script used for automated builds: setup-build-android and look for apt-get calls.

On Mandriva, ROSA or Unity

This has been tested on Cooker, package names may vary slightly for older releases.

  • sudo urpmi git-core gnupg flex bison gperf task-c++-devel zip curl lib64z-devel ncurses-devel x11-proto-devel lib64x11-devel lib64uuid-devel lib64gl-devel lib64readline-devel java-1.6.0-openjdk-1.6.0.0 java-1.6.0-openjdk-devel ant

Quickstart

Download 'repo' tool and Product manifest repository

PRODUCT_GROUPS referenced below defines which hardware and feature specific subdirectories will be included. It is a comma separated list and should always include "common". Outside of common, options are: {devel,arndale,pandaboard,snowball,vexpress,vexpress-iks,hisilicon,galaxynexus,vexpress-tests,nexus4,nexus7,imx53} (The manifest file is typically updated more often than the documentation, so you may want to check the manifest.xml file for further options)

$ mkdir ~/bin/
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ export PATH=$HOME/bin:$PATH
$ chmod a+x ~/bin/repo
$ repo init -u http://android.git.linaro.org/git-ro/platform/manifest.git -b linaro_android_4.2.2 -g {PRODUCT_GROUPS}
$ repo sync

See Platform/Android/GetSource for details on how to get the Linaro Android source code.

Build using linaro-android toolchain in current builds

Current builds include the linaro-android toolchain inside the source tree. Simply use

$ make TARGET_PRODUCT={TARGET_PRODUCT} TARGET_TOOLS_PREFIX=prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.7-linaro/bin/arm-linux-androideabi- boottarball systemtarball userdatatarball

Build using linaro-android toolchain in older builds

To use the Linaro toolchain with builds predating its addition to the repo tree, use the proper toolchain platform branch as mentioned on Platform/Android/GetSource and pass the proper TARGET_TOOLS_PREFIX pointing to the Linaro toolchain.

Download and extract linaro-android toolchain (always try to use the latest version), e.g.:

$ wget --no-check-certificate http://android-build.linaro.org/builds/~linaro-android/toolchain-4.6-2011.12/5/android-toolchain-eabi-linaro-4.6-2011.12-5-2011-12-12_14-40-40-linux-x86.tar.bz2
$ tar -jxvf android-toolchain-eabi-linaro-4.6-2011.12-5-2011-12-12_14-40-40-linux-x86.tar.bz2

Start the build for any or all of the available TARGET_PRODUCTs {pandaboard, snowball, origen, iMX53, iMX6}, assuming you have unpacked Linaro toolchain in /opt:

$ make TARGET_PRODUCT={TARGET_PRODUCT} TARGET_TOOLS_PREFIX=/opt/android-toolchain-eabi/bin/arm-linux-androideabi- boottarball systemtarball userdatatarball

Building Android platform code with default 4.4.x prebuilt toolchain

$ make TARGET_PRODUCT={TARGET_PRODUCT} TARGET_TOOLS_PREFIX=prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi- boottarball systemtarball userdatatarball

Create SD card images

Create SD card images for booting using linaro-android-image-create Platform/Android/ImageInstallation

where DEVICE = {origen, mx53loco, iMX53, mx6qsabrelite, vexpress-a9, panda, snowball_sd, snowball_emmc} and sd'X' is the device node of SD card on HOST machine.

$ bzr branch lp:linaro-image-tools
$ ./linaro-image-tools/linaro-android-media-create --mmc /dev/sd{X} --dev {DEVICE} --system out/target/product/{TARGET_PRODUCT}/system.tar.bz2 --userdata out/target/product/{TARGET_PRODUCT}/userdata.tar.bz2 --boot out/target/product/{TARGET_PRODUCT}/boot.tar.bz2

If you don't want to build the code yourself then releases are available on http://releases.linaro.org , and daily images for official builds can be found on https://android-build.linaro.org/

Extras

Initializing build environment

Initializing a build environment can be pretty useful at times.

$ . build/envsetup.sh

It provides handy shortcuts. Specifically:

- croot:   Changes directory to the top of the tree.
- m:       Makes from the top of the tree.
- mm:      Builds all of the modules in the current directory.
- mmm:     Builds all of the modules in the supplied directories.
- cgrep:   Greps on all local C/C++ files.
- jgrep:   Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir:   Go to the directory containing a file.

Known issues and workarounds

Divergence from Google's standard build instructions

Google's build instructions include an extra step where 'lunch' is used to select a build target:

   1 . build/envsetup.sh
   2 lunch
   3 make

Since we specify the TARGET_PRODUCT and TARGET_TOOLS_PREFIX on the make command line, lunch is redundant, so can be skipped. There should be no difference in the build whether you run lunch or not.

Error about undefined __vmi_class_type_info

out/target/product/pandaboard/obj/lib/libOpenSLES.so: undefined reference to `typeinfo for android::SortedVectorImpl'
out/target/product/pandaboard/obj/lib/libOpenSLES.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
collect2: ld returned 1 exit status
make: *** [out/target/product/pandaboard/obj/EXECUTABLES/BufferQueue_test_intermediates/LINKED/BufferQueue_test] Error 1

Workaround

https://bugs.launchpad.net/linaro-android/+bug/732564

Patch

IAndroidEffect_error.patch

This has been fixed since the 11.04 release. Update your build.

Error "FORTIFY_SOURCE"

> <command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined
> [enabled by default]
> <built-in>:0:0: note: this is the location of the previous definition

Cause

Some broken host compilers (such as the ones shipped with Ubuntu Oneiric) are patched incorrectly to define _FORTIFY_SOURCE by default, without allowing for overrides on the command line (resulting in the error).

Fix

This has been fixed in platform/build/core commit 94e7efa797db060258d91ff611cea90cc0088681 Update to a release >= 12.04 or current git, or pull in that commit into your current build by running e.g.

cd build/core
git pull
git cherry-pick 94e7efa797db060258d91ff611cea90cc0088681

Workaround

If you don't want to apply the fix for some reason, you can work around the issue by using a different host compiler -- e.g. build Linaro gcc for the host from source, or use gcc-4.5 (which doesn't include the bogus patch) by adding this to the build environment (e.g. by passing it on the make command line):

HOST_CC=gcc-4.5 HOST_CXX=g++-4.5 HOST_CPP=cpp-4.5


CategoryAndroidTips

Platform/Android/BuildSource (last modified 2014-12-09 07:34:24)