您的位置:首页 > 移动开发 > Android开发

Android 源码的下载及编译

2011-03-29 16:15 477 查看
Ubuntu 下,下载Android源码非常简单, 下面是我摸索下载 Android2.3 源码时的一些心得,抽点时间,把它写下来...

1. 首先配置源码下载环境,在终端上敲入 sudo apt-get install git-core curl , 待安装成功.

2. 安装 repo 脚本,在终端上敲入 curl http:// href="http://www.linuxidc.com/topicnews.aspx?tid=11" target=_blank>Android.git.kernel.org/repo >~/repo , 待安装成功.

3. 进入home 目录,看下repo 是否有可执行权限,若没有的话须添加执行权限,在终端上敲入 chmod a+x ~/repo

4. 在终端上敲入 ~/repo init -u git://Android.git.kernel.org/platform/manifest.git 初始化,其间会提示用户输入姓名,邮箱,随意输入即可.

5. 在终端上敲入 ~/repo sync 等待下载

6. 下载完成时,终端上会显示 Syncing work tree: 100% ,done ,Android 2.3 总共有>=3.1G , 在下载过程中若出现网络中断,可以在终端上敲入 ~/repo sync,继续下载

下载完成后,键入 make 命令开始编译,第一次编译时比较麻烦,可能会出现一些的问题,下面是我在编译过程中遇到的一些问题(Ubuntu 10.10 32 bit system, JDK1.6) :

question 1 :

build/core/main.mk:73: You are attempting to build on a 32-bit system.
build/core/main.mk:74: Only 64-bit build environments are supported beyond froyo/2.2.
这是因为froyo/2.2默认只支持64-bit。
解决办法:需要进行如下修改即可,将
./external/clearsilver/cgi/Android.mk
./external/clearsilver/java-jni/Android.mk
./external/clearsilver/util/Android.mk
./external/clearsilver/cs/Android.mk
四个文件中的
LOCAL_CFLAGS += -m64
LOCAL_LDFLAGS += -m64
注释掉,或者将“64”换成“32”

LOCAL_CFLAGS += -m32
LOCAL_LDFLAGS += -m32

然后,将
./build/core/main.mk 中的
ifneq (64,$(findstring 64,$(build_arch)))
改为:
ifneq (i686,$(findstring i686,$(build_arch)))
question 2 :

external/clearsilver/cgi/cgi.c:22: fatal error: zlib.h: No such file or directory
compilation terminated.

解决: sudo apt-get install zlib1g-dev

question3:

bison -d -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
/bin/bash: bison: command not found

解决: sudo apt-get install bison

question4:

Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
/bin/bash: flex: command not found

解决: sudo apt-get install flex

question5:

/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status

解决: sudo apt-get install lib32ncurses5-dev,如果不能安装可以再次输入sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev 试试

question6:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.

解决: sudo apt-get install libx11-dev

question7:
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 96.

解决: sudo apt-get install gperf

然后编译即可。。。

上述是我第一交编译 android 源码出现的错误,多谢这篇文章的作者 http://www.linuxidc.com/Linux/2011-03/33564.htm 助我编译成功。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: