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!