Building Android 4.0.3 on Ubuntu 12.04

To build android source code on Ubuntu12.04, it’s better use:

     Linux-64bit
     16GBRAM or 16 GB SWAP cache, the more, the better
     30GB or more Disk space


To initialize the building environment, JDK must be installed and added to the environment:

 

    Java 7: for the master brance
    Java 6: for Gingerbread through KitKat
    Java 5: for Cupcake through Froyo

Execute the command below to install the required packages:

    $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


The process of Android source building needs a huge memory space, to set up the CCACHE, put the following in your.bashrc or equivalent:

    export USE_CCACHE = 1
    export CCACHE_DIR = < path to your cache directory >                                 # in ~/.ccache by default

After downloaded the source, run the command:

    prebuilts/misc/linux-x86/ccache/ccache-M 50G

Using a separate output directory, export the OUT_DIR_COMMON_BASE variable:

    export OUT_DIR__COMMON_BASE = < path to your out directory >

Then comes the most difficult and time spending work, downloading the source code. Because of the great wall, it’susually impossible to access the data of source.android.com. Here I download the source from another website, the version is 4.0.3.

Execute “ $ source build/envsetup.sh “ toinitialize the environment.

Execute “ $ lunch “ to select a target.

Execute “ $ make –j16 “ to start thebuilding.

 


Here are some problems I encountered during the process of building, and the way to fix these problems:

Problem1: _FORTIFY_SOURCE" redefined [-Werror]

This compile error is due to GCC4.6 in your environment. To solve this problem,change the source code of /build/core/combo/HOST_linux-x86.mk. Change the statement :

HOST_GLOBAL_CFLAGS+= -D_FORTIFY_SOURCE = 0  to

HOST_GLOBAL_CFLAGS+= -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

 

Problem2: /usr/bin/ld: cannot find –lXXX    collect2: ld returned 1 exit status

This problem usually appears on x64 machines. To fix the problem above, run"sudo apt-get install lib32ncurses5-dev" to install 32bit libs.

 

Problem3: external/mesa3d/src/glsl/ir_visitor.h:48:17: warning: ‘virtual void ir_visitor::visit(ir_function_signature*)’ was hidden [-Woverloaded-virtual]

external/mesa3d/src/glsl/ir_visitor.h:81:17:warning:   by ‘ir_control_flow_visitor::visit’[-Woverloaded-virtual]

This problem can be solved by adding "#include <stddef.h>" or "#include <cstddef>" to external/mesa3d/src/glsl/linker.cpp

 

Problem4: external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error:‘ptrdiff_t’ does not name a type.

To fix this error, modify the code of  “external/gtest/include/gtest/internal/gtest-param-util.h”:

 #include <vector>

+#include<cstddef>  // Adding this line

 #include <gtest/internal/gtest-port.h>

 

Problem5: frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]

cc1plus:all warnings being treated as errors

In file “frameworks/compile/slang/Android.mk”, modify it as below:

-local_cflags_for_slang:= -Wno-sign-promo -Wall -Wno-unused-parameter -Werror // Delete it

+local_cflags_for_slang:= -Wno-sign-promo -Wall -Wno-unused-parameter // Add this

 

Problem6 : No USB Permission error:

On most Linux systems, unprivileged users cannot access USB ports by default. If you see a permission denied error, create a file /etc/udev/rules.d/51-android.rules (as the root user) and to copy the following lines in it. <username> must be replaced by the actual username of the user who is authorized to access the phones over USB.

# adb protocol onpassion (Nexus One)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12",MODE="0600", OWNER="<username>"
# fastboot protocolon passion (Nexus One)
SUBSYSTEM=="usb",ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff",MODE="0600", OWNER="<username>"
# adb protocol oncrespo/crespo4g (Nexus S)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22",MODE="0600", OWNER="<username>"
# fastboot protocolon crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20",MODE="0600", OWNER="<username>"
# adb protocol onstingray/wingray (Xoom)
SUBSYSTEM=="usb",ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9",MODE="0600", OWNER="<username>"
# fastboot protocolon stingray/wingray (Xoom)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c",MODE="0600", OWNER="<username>"
# adb protocol onmaguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb",ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860",MODE="0600", OWNER="<username>"
# fastboot protocolon maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30",MODE="0600", OWNER="<username>"
# adb protocol onpanda (PandaBoard)
SUBSYSTEM=="usb",ATTR{idVendor}=="0451",ATTR{idProduct}=="d101", MODE="0600",OWNER="<username>"
# adb protocol onpanda (PandaBoard ES)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1",ATTR{idProduct}=="d002", MODE="0600",OWNER="<username>"
# fastboot protocolon panda (PandaBoard)
SUBSYSTEM=="usb",ATTR{idVendor}=="0451",ATTR{idProduct}=="d022", MODE="0600",OWNER="<username>"
# usbboot protocolon panda (PandaBoard)
SUBSYSTEM=="usb",ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f",MODE="0600", OWNER="<username>"
# usbboot protocolon panda (PandaBoard ES)
SUBSYSTEM=="usb",ATTR{idVendor}=="0451",ATTR{idProduct}=="d010", MODE="0600",OWNER="<username>"
# adb protocol ongrouper/tilapia (Nexus 7)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42",MODE="0600", OWNER="<username>"
# fastboot protocolon grouper/tilapia (Nexus 7)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40",MODE="0600", OWNER="<username>"
# adb protocol onmanta (Nexus 10)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2",MODE="0600", OWNER="<username>"
# fastboot protocolon manta (Nexus 10)
SUBSYSTEM=="usb",ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0",MODE="0600", OWNER="<username>"

If the building process goes well, there will be 3 images in out/target/product/generic:system.img, userdata.img, ramdisk.img. To run your android, you can execute “emulator” after building (as the android official website say…). But it doesn’t work for me.

 

In my window 7 system, I installed adt-bundle which contains the AVD manager, so I use it to run my own android image.

Create “android-15”in the path sdk/system-images/.

Download android 4.0 system image, open it with zip, drag the folder “armeabi-v7a” into sdk/system-images/android-15/.

Download ndroid SDK API level, open it with zip, drag the folder “android-4.0.x” into sdk/platforms/, rename the folder as “android-15”.

Replace the three images in sdk/system-images/android-15/armeabi-v7a with your own images.

Open the eclipse IDE tool in the adt-bundle, create an AVD device of android-15.

Start your own Android !

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值