`
zhonglunshun
  • 浏览: 134807 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

如何单独编译安卓系统源码指定模块

 
阅读更多


 

如何单独编译安卓系统源码指定模块

 



 

昨天花了一天的时间编译android系统源码,我在想要是用家里那台老爷车编译起码需要几天时间了,好了,言归正传,这篇讲怎么编译单独的app,以及重新打包system.img。单独编译我们需要用到mmm命令。

 

1.获取mmm命令:

 

Android源代码目录下的build目录下,有个脚本文件envsetup.sh,执行这个脚本文件后,就可以获得一些有用的工具:

 

~/Android_Dev/Android4_4source $ . ./build/envsetup.sh

 

执行后可能会出现这个错误:build/envsetup.sh: 1: Syntax error: "(" unexpected 若没有请跳过。有的话执行$sudo dpkg-reconfigure dash命令,并选择“否”就能修正。

 

回车之后会出现一些东西。其实,这是一个source命令,执行之后,就会有一些额外的命令可以使用:

 

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.

 

在这里,我们只关注mmm命令,用它编译指定模块用mmm就好了。

 



 

2.开始编译指定模块(以email app为例):

 

~/Android_Dev/Android4_4source $ mmm packages/apps/Email/

 

然后我的电脑上开始编译了,编译到了后面出现了个小问题:

 

make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/sdk_v18_intermediates/classes.jar', needed by `out/target/common/obj/APPS/Email_intermediates/classes-full-debug.jar'. Stop.

 

这个错误是因为我偷懒没有把系统编译完成就单独编译,这样子是不行的,于是我开始重新编译整个系统。

 



 

编译完成之后,我们可以在out/target/product/generic/system/app目录下看到Email.apk文件了。android系统自带的app都放在这个目录下,另外android系统的一些可执行文件,放在out/target/product/generic/system/lib目录下,硬件层(HAL)接口文件放在out/target/product/generic/system/lib/hw,编译好模块后,还需要重新打包system.img文件以便在模拟器上运行的时候看到效果。使用:$ make snod命令

 



 

 

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics