1. 修改内核以后,不用每次都去make编译,只需mm对模块进行编译就可以。 在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 重新生成system.img
2. mm编译HelloWorld.apk
把HelloWorld目录拷贝到android_src/packages/apps目录下。 编辑Android.mk文件:
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := HelloWorld
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
# Use the folloing include to make our test apk. include $(call all-makefiles-under,$(LOCAL_PATH))
然后
cd packages/apps/HelloWorld
mm
生成的文件:
out/target/product/generic/system/app/HelloWorld.apk
3. 任意的目录下编译app
如果把应用程序放到packages/apps下, 感觉很不爽!
那么运行下面的命令,或者写道.bashrc中
source ~/andorid_src/build/envsetup.sh
export TOP=~/android_src
然后进入eclipse的workspace的HelloWorld下进行mm也可以了!生成的apk路径同上。
注意如果你有两份android源码,换另一份源码进行mm,则要重新配置TOP,否则就算你在另一份android_src_2.3.3/packages/apps/HelloWorld下mm,也用的是android2.2的mm!