在Ubuntu 10.04系统(32位)上下载和编译google Android2.3.7最新版源码

在Ubuntu 10.04系统 32位机上安装编译Android2.3源码(本文所有内容参考自:http://source.android.com): 

1.安装JDK6 (www.oracle.com),配置环境变量(JAVA_HOME和PATH)。

2. 安装各种必要的开发包:

$ sudo aptitude install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev 

the packages above seem enough and work well and belows from source.android.com for android 2.3 gingerbread: 
Installing required packages 
To set up your development environment, install the following required packages: 

$ 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 lib32readline5-dev lib32z-dev \   libgl1-mesa-dev g++-multilib mingw32 tofrodos 

3. 安装Repo (source.android.com) 并下载源码: 
Android2.3$ repo init -u https://android.googlesource.com/platform/manifest -b gingerbread 
in the echos of the console, you can see all versions or branches available. 

下载:

Android2.3$ repo sync

注意: 如果出现下载频繁中断,可以尝试下面二行命令: 

Android2.3$ sudo sysctl -w net.ipv4.tcp_window_scaling=0 
Android2.3$ repo sync -j1 

下载过程非常慢(视具体网络情况),一般花8小时到数天左右时间才能完全下完,下载完后注意阅读log的最后一行以确认下载的源码是否完整。


5. 编译Android2.3 

$ cd ~/Android2.3 

$ . build/envsetup.sh 

$ lunch full-eng // 编译模拟器版本,如果要为nexus s真机编译,并在nexus s真机上体验刚编译好的系统,可见我的博文:编译google官方源码android2.3.7并刷到nexus s(i9020)完美运行(http://blog.youkuaiyun.com/foreveryoung001/article/details/7639848

$ make -j4  // 如果出现莫名错误,可尝试清空out后再次用make -j1进行编译
note: 
1. no need to pay attention to whether 32-bit or 64-bit your system is, because the source project auto detect the very version(32-bit or 64-bit) the jdk is and use the version same as jdk or your os. 

2. 在编译时,要注意环境变量,因为gcc的库也在环境变量中,所以如果你最近用. /etc/profile重新修改了(实际上很有可能已改变了)相关的环境变量的值中的路径的先后顺序,而可能导致有些库找不到(因为编译命对需要的库的先后顺序有依赖,如果解析的某个库引用到了其后面的库(这个后面的库此还没有被解析)于是出现了找不到相应的库的错误,这种情况下,一般注销后重新登录会让环境变量还原从而解决问题)! 

注:用的svn版的编译时找不到库:arm-eabi-g++: libgcc.a: No such file or directory,但用原始版(非svn库中的源码)编译过程完全正常(可能是没有完全将完整的源码上传到svn库中所致)。 

3. 生成的文件在:and2.3.7/out/target/product/generic下,root打包后是ramdisk.img,system打包后是system.img。注意要想运行编译得到的系统,还需要编译整个sdk(如果不想丢失之前编译的内容,最好作个备份,否则大量文件会丢失,丢失后,如果再想生成,需要在编译完sdk后再编译整个系统,非常浪费时间): 

$ make PRODUCT-sdk-sdk 

编译得到的sdk中的platforms/android-2.3.7/images/armeabi-v7a有kernel,这时注意该sdk的版本(2.3.3,android2.3.7编译得到的sdk也是2.3.3)与eclipse adt的版本关系,如果你下的adt版本比你编译的SDk配套的adt(可以自行编译adt,但一般没有必要,而编译sdk可能是必须的,因为我将系统生成的镜像覆盖标准sdk中相应的镜像后并没有成功启动模拟器,而编译得到的SDK则可以正常运行模拟器,用系统生成的镜像覆盖编译得到的sdk中相应的镜像也可以正常运行)版本要高的话,则必须更新你编译得到的sdk的相关包:在sdk manager中下载最新的tools和platform-tools即可在eclipse中正常使用该sdk了。另外,在运行模拟器后,可以查看具体的android操作系统的版本号,此时为2.3.7(对比:此时的sdk版本为2.3.3).通过编译得到的sdk中包含的system.img要比make整个系统后生成的system.img要大,前者为106.0M后者为84.9M,当然,用后者覆盖前者(在$ANDROID_SDK_HOME/platforms/android-2.3.7/images/armeabi-v7a下)也一样可以正常运行Android并且系统版本也为2.3.7. 

模块或系统级应用的编译( http://mcuos.com/redirect.php?tid=4553&goto=lastpost): 
Android中的一个应用程序可以单独编译,编译后需要重新生成system.img。 
在Android目录下运行 
$ . build/envsetup.sh  或者 
$ source build/envsetup.sh ,然后就会多出几个可用的命令: 
- 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. 
- printconfig: 当前build的配置情况. 
可以使用 --help查看用法。 
如:在修改了某一个模块以后,可以使用 $ mmm <目录>  来重新编译所有在<目录>中的所有模块,使用 $ mm  编译当前目录中的所有模块。 
编完之后,即修改了Android系统以后,可以使用 $ make snod(http://blog.youkuaiyun.com/foreveryoung001/article/details/7640046) 重新生成system.img 
(end)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值