2024年6月6日发(作者:)
-
Android驱动开发例如及系统编译
1根底局部
在Ubuntu上下载、编译和安装Android最新源代码
看完了前面说的几本书之后,对Linu* Kernel和Android有一定的认识了,是不是心里蠢
蠢欲动,想小试牛刀自己编译一把Android源代码了呢.一直习惯使用Windows系统,而
Android源代码是不支持在Windows上编译上,于是决定使用虚拟机安装Ubuntu,然后下载、
编译和安装Android源代码。
一. 环境准备
1. 磁盘空间预留20G左右,存3G,因为一边要跑主机,一边要跑虚拟机,存要求还是比拟
高的,这样才会比拟流畅。
2. 安装VMWare 7.1.4。我的操作系统是Win7,VMWare的版本要新一点的,旧版本的VMWare
在网络支持上比拟差,由于要在虚拟机上下载Android源代码,没有网络是万万不行的。
3. 安装好VMWare后,接下来就安装Ubuntu系统了。我选择目前最新的版本
ubuntu-11.04-alternate-i386,从网上查到的资料说,要编译Android源代码,Ubuntu的
最低版本是8.04。下载好后,安装时采用一直默认安装即可。
4. 安装Git工具。Android源代码采用Git工具来管理,与SVN相比,这是一种分布式的
源代码管理工具,而SVN是集中式的源代码管理工具。要安装Git工具,在Ubuntu上执行
以下命令即可:
USER-NAMEMACHINE-NAME:~$ sudo apt-get install git-core gnupg
5. 安装Java SDK。在Ubuntu上执行以下命令:
USER-NAMEMACHINE-NAME:~$ sudo add-apt-repository ppa:ferramroberto/java
USER-NAMEMACHINE-NAME:~$ sudo apt-get update
USER-NAMEMACHINE-NAME:~$sudo apt-get install sun-java6-jre sun-java6-plugin
USER-NAMEMACHINE-NAME:~$ sudo apt-get install sun-java6-jdk
6. 依赖的其它包。在Ubuntu上执行以下命令:
USER-NAMEMACHINE-NAME:~$ sudo apt-get install fle* bison gperf libsdl-dev
libesd0-dev libw*gtk2.6-dev build-essential zip curl
7. 调试工具。在Ubuntu上执行以下命令:
USER-NAMEMACHINE-NAME:~$ sudo apt-get install valgrind
二. 下载Android源代码工程
1. 下载repo工具。在Ubuntu上执行以下命令:
USER-NAMEMACHINE-NAME:~$ wget
. z
-
s://./dl/googlesource/git-repo/repo
USER-NAMEMACHINE-NAME:~$ chmod 777 repo
USER-NAMEMACHINE-NAME:~$ cp repo /bin/
2. 下载Android最新版根源代码。在Ubuntu上执行以下命令:
USER-NAMEMACHINE-NAME:~$ mkdir Android
USER-NAMEMACHINE-NAME:~$ cd Android
USER-NAMEMACHINE-NAME:~/Android$ repo
init -u s://./dl/googlesource/git-repo/repo
USER-NAMEMACHINE-NAME:~/Android$ repo sync
经过漫长的等待〔我下载了两三天〕后,就可以把Android源代码下载下来了。其间可能还
有经历下载中断的情况,这时只要重新执行repo sync就可以了。
三. 编译Android源代码
1. 编译
在Android目录下执行以下命令:
USER-NAMEMACHINE-NAME:~/Android$ make
第一次编译要等待比拟久的时间,编译成功后,可以看到下面的输出:
Target system fs image:
out/target/product/generic/obj/PACKAGING/systemimage_intermediates/
Install system fs image: out/target/product/generic/
Target ram disk: out/target/product/generic/
Target userdata fs image: out/target/product/generic/
Installed file list: out/target/product/generic/installed-files.t*t
2. 编译过程中可能会遇到的问题。
问题一:You are attempting to build on a 32-bit system.
两个地方需要个修改:
1〕修改build/core目录下的文件:
ifeq ($(BUILD_OS),linu*)
build_arch := $(shell uname -m)
*Change the following line for building on a 32-bit system.
*ifneq (64,$(findstring 64,$(build_arch)))
ifneq (i686,$(findstring i686,$(build_arch)))
$(warning ************************************************************)
$(warning You are attempting to build on a 32-bit system.)
$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
2〕找到以下文件:
/e*ternal/clearsilver/cgi/
/e*ternal/clearsilver/cs/
/e*ternal/clearsilver/java-jni/
/e*ternal/clearsilver/util/
修改LOCAL_CFLAGS和LOCAL_LDFLAGS变量:
* This forces a 64-bit build for Java6
* Change the following two lines for building on a 32-bit system.
. z


发布评论