由於AOSP 項目太大,我只修改了一個模塊,比如設置。
那么只需要單獨編譯設置這個模塊就可以了。
首先執行Source:
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.
這些命令的具體用法,可以在命令的后面加-help來查看,這里我們只關注mmm命令,也就是可以用它來編譯指定目錄的所有模塊,通常這個目錄只包含一個模塊。
修改設置apk
設置apk 的項目在aosp/packages/apps/Settings下,我們在里面加上一個toast.
修改之后,lunch 一下
lunch
然后指定自己編譯的模塊
接着,使用mmm命令來編譯指定的模塊,例如系統的設置應用程序:
// 編譯設置模塊
mmm packages/apps/Settings/
//將編譯過得設置模塊寫到system.img里面去
make snod
//清楚數據啟動模擬器
emulator -wipe-data
mmm packages/apps/Settings/ 編譯完成之后,就可以在out/target/product/generic_x86_64/system/product/priv-app/Settings/Settings.apk目錄下看到apk文件了。如上圖
make snod 之后,就可以在out/target/product/generic_x86_64/system.img目錄下看到img文件了。如上圖
修改系統apk 之后的效果如下
我修改了系統的設置,每次onResume 就會彈出一個toast 。
我錯了,上面說的方法不行。還是要重新編譯一下System.img
我又嘗試了下,簡單的make snod 不會生效。
還是需要make -j8
全部編譯一下。
注意:
一定要emulator -wipe-data
否則你修改的內容可能不生效!我自己嘗試了幾次,才知道要這樣做的!
網上沒有人說要清楚數據。不知道他們都只是copy 別人的博客,還是怎么樣。。。