如何單獨編譯Android原始碼中的模組

來源:互聯網
上載者:User

標籤:

如何單獨編譯Android原始碼中的模組 - 老羅的Android之旅 - 部落格頻道 - CSDN.NET

? ? ?第一次下載好Android原始碼工程後,我們通常是在Android原始碼工程目錄下執行make命令,經過漫長的等待之後,就可以得到Android系統鏡像system.img了。以後如果我們修改了Android原始碼中的某個模組或者在Android原始碼工程新增一個自己的模組,是不是還是執行make命令呢?答案是否定的,Google為我們準備了另外的命令來支援編譯單獨的模組,以及重新打包system.img的命令。在繼續學習Android原始碼之前,就讓我們先來看看這個命令吧。

?? ? ?一. 首先在Android原始碼目錄下的build目錄下,有個指令檔envsetup.sh,執行這個指令檔後,就可以獲得一些有用的工具:

?? ? ?[email protected]:~/Android$Snbsp;. ?./build/envsetup.sh

?? ? ?注意,這是一個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.?? ? ?這些命令的具體用法,可以在命令的後面加-help來查看,這裡我們只關注mmm命令,也就是可以用它來編譯指定目錄的所有模組,通常這個目錄只包含一個模組。?? ? ?二. 使用mmm命令來編譯指定的模組,例如Email應用程式:?? ? ? [email protected]:~/Android$Snbsp;mmm packages/apps/Email/ ?? ? ?編譯完成之後,就可以在out/target/product/generic/system/app目錄下看到Email.apk檔案了。Android系統內建的App都放在這具目錄下。另外,Android系統的一些可執行檔,例如C編譯的可執行檔,放在out/target/product/generic/system/bin目錄下,動態連結程式庫檔案放在out/target/product/generic/system/lib目錄下,out/target/product/generic/system/lib/hw目錄存放的是硬體抽象層(HAL)介面檔案,後面的文章裡面,我們會陸續提及到,敬請關注。?? ? ?三. 編譯好模組後,還要重新打包一下system.img檔案,這樣我們把system.img運行在模擬器上時,就可以看到我們的程式了。?? ? ? [email protected]:~/Android$Snbsp;make snod ?? ? ?四. 參照Ubuntu上下載、編譯和安裝Android最新原始碼一文介紹的方法運行模擬器:?? ? ? [email protected]:~/Android$ emulator ?? ? ?這樣一切就搞定了。

如何單獨編譯Android原始碼中的模組

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.