如何编译android4(Ubuntu11.10)

完全是一个全新的系统,如何编译android4.0?其实很简单。

1.访问地址http://source.android.com/source/initializing.html

2.按照指示安装一些工具:

$sudoapt-getinstalllibx11-dev:i386

JDK:

$sudoadd-apt-repository"debhttp://archive.canonical.com/lucidpartner"

$sudoapt-getupdate

$sudoapt-getinstallsun-java6-jdk

Python:

$sudoapt-getinstallpython

Git

$sudoapt-getinstallgit

Curl

$sudoapt-getinstallcurl

g++

$sudoapt-getinstallg++

zlib

$sudoapt-getinstallzlib1g-dev

$sudoapt-getinstalllib64z1-dev

bison

$sudoapt-getinstallbison

flex

$sudoapt-getinstallflex

ncurses

$sudoapt-getinstalllibncurses5-dev

GL

$sudoapt-getinstalllibgl1-mesa-dev

gpref

$sudoapt-getinstallgpref

3.http://source.android.com/source/downloading.html

$mkdir~/bin

$PATH=~/bin:$PATH

$curlhttps://dl-ssl.google.com/dl/googlesource/git-repo/repo>~/bin/repo

$chmoda+x~/bin/repo

$mkdirWORKING_DIRECTORY

$cdWORKING_DIRECTORY

$repoinit-uhttps://android.googlesource.com/platform/manifest-bandroid-4.0.1_r1

$reposync

4.build/core/config.mk

去掉Werror这行(目的是不要把warnings当成errors)

5.

修改geditframeworks/base/libs/utils/Android.mk

将:

LOCAL_CFLAGS+=-DLIBUTILS_NATIVE=1$(TOOL_CFLAGS)

改为:

LOCAL_CFLAGS+=-DLIBUTILS_NATIVE=1$(TOOL_CFLAGS)-fpermissive

6.

修改文件

external/oprofile/libpp/Android.mk

external/oprofile/pp/Android.mk

LOCAL_CFLAGS:=$(common_host_cflags)

改为

LOCAL_CFLAGS:=$(common_host_cflags)-fpermissive

7.

修改make文件

frameworks/base/tools/aapt/Android.mk

frameworks/base/tools/localize/Android.mk

将这几句

ifeq($(HOST_OS),linux)

LOCAL_LDLIBS+=-lrt

endif

改为

ifeq($(HOST_OS),linux)

LOCAL_LDLIBS+=-lrt-lpthread

endif

8.

修改源码目录下/build/core/combo/HOST_linux-x86.mk文件:

将以下语句

HOST_GLOBAL_CFLAGS+=-D_FORTIFY_SOURCE=0

修改为

HOST_GLOBAL_CFLAGS+=-U_FORTIFY_SOURCE-D_FORTIFY_SOURCE=0

9.

$viexternal/gtest/src/../include/gtest/internal/gtest-param-util.h

+#include<cstddef>

10.http://source.android.com/source/building.html

$sourcebuild/envsetup.sh

$lunchfull-eng

$make-j4

相关推荐