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

Android源码 模块编译

2016-02-26 18:26 429 查看
有的时候,我们需要单独编译某个模块,然后打包到 Android Rom 中去。

命令介绍

先介绍几个模块编译的命令:

m: Makes from the top of the tree. (编译所有的模块 )

mm: Builds all of the modules in the current directory. (编译当前目

录下的模块,当前目录下要有Android.mk文件)

mmm: Builds all of the modules in the supplied directories. (编译指定路径下的模块,指定路径下要有Android.mk文件)

模块编译

首先,我们需要进入到源码目录下

$ cd android_source_v5/alps/alps/


比如,我们需要编译 Settings 的源码

$ . build/envsetup.sh
or source build/envsetup.sh
然后执行编译命令
$ mmm packages/apps/Settings


编译成功,会出现以下界面



记住出现的这行代码(很重要)

Install: out/target/product/lcsh6580_weg_sh_l/system/priv-app/Settings/Settings.apk

编译成功的apk输出目录在:out/target/product/lcsh6580_weg_sh_l/system/priv-app/Settings/Settings.apk

安装 apk 查看效果

编译完成过后,我们总需要看一下效果,有 bug 也需要 fix 的。

$ adb install -r out/target/product/lcsh6580_weg_sh_l/system/priv-app/Settings/Settings.apk




然后就可以在设备上查看运行结果啦~

把模块编译的 apk 打包到真个 system.img 中去

模块编译完成,有时候需要打包到系统镜像中,然后发布给所有人用,主要是不想每个单独更新某个 apk 麻烦~

$ lunch
选择你需要编译的设备源码
$ make snod
将你修改的模块打入到system.img中




打包成功~

下面就是重新刷机啦~

$ adb reboot bootloader
$ fastboot flashall -w


这样重新刷机过后,也能看到设备上新的 apk , 然后验证效果。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: