04 在ubuntu 環境中,編輯  Android 原始碼

04 在ubuntu 環境中,編輯 Android 原始碼

Building the System

The basic sequence of build commands is as follows:

Initialize

Initialize the environment with the envsetup.sh script. Note that replacing “source” with a single dot saves a few characters, and the short form is more commonly used in documentation.

$ source build/envsetup.sh

Choose a Target

Choose which target to build with lunch. The exact configuration can be passed as an argument, e.g.

$ lunch full-eng

進去 make,今天如果你的電腦是多 CPU 記得加個 j,如範例 -j 雙核心

make -j(核心數)

make -j2

我是選四核心的


$ make -j4

編譯 Android Source Code

等等等…,現在一般的個人電腦大概要編 4 小時
差一點的可能會多很多我用舊筆電跑 12 小時
完以後在 /android_22/out/target/product/generic
會看到以下三個檔案

ramdisk.img
system.img
userdata.img

請將這3個檔案複製到你的 Android SDK
像我自己從android-8複製了一個 android-9
在把以下路徑的3個img換掉

C:\Labs\Android\AndroidSDK\platforms\android-9\images

你在開發時就可以使用自己編的 android 了
切來切去有點煩,全部改 Linux 開發好了

練習:

請在 ubuntu 上使用 firefox 在 applications->internet-> firefox web browser.

和 使用 movie player  在 applications->Sound&Video ->  movie player  .

看看用作是否一切正常

進階:

其實安裝ubuntu 64 bit 也是一個不錯的選擇,速度又快,如果你的硬體支援的話,可以嘗試安裝使用ubuntu 64 bit 版。