完整版linux下android源碼下載、編譯、模擬器啓動運行

一、環境說明:

1、VMware版本:8.0.3 build-703057

2、liunx系統:Ubuntu10.10

3、jdk:sun-java6-jdk

二、Ubuntu 10.10更新源列表

      由於Ubuntu 10.10版本的源已經過期了,所以,需要對其進行更新,Ubuntu 10.10 已經發布了,下面提供更新源方法與更新源列表地址:   

1.sudo gedit /etc/apt/sources.list
     編輯你的源列表,將原來的內容全部刪除,添加下面的源,複製到你的列表中,然後保存列表。

## Major bug fix updates produced after the final release of the 
## distribution. 
deb http://old-releases.ubuntu.com/ubuntu/ maverick main restricted 
deb-src http://old-releases.ubuntu.com/ubuntu/ maverick main restricted 
deb http://old-releases.ubuntu.com/ubuntu/ maverick-updates main restricted 
deb-src http://old-releases.ubuntu.com/ubuntu/ maverick-updates main restricted 
  
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team. Also, please note that software in universe WILL NOT receive any 
## review or updates from the Ubuntu security team. 
deb http://old-releases.ubuntu.com/ubuntu/ maverick universe 
deb-src http://old-releases.ubuntu.com/ubuntu/ maverick universe 
deb http://old-releases.ubuntu.com/ubuntu/ maverick-updates universe 
deb-src http://old-releases.ubuntu.com/ubuntu/ maverick-updates universe 
  
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu 
## security team. 
deb http://old-releases.ubuntu.com/ubuntu/ maverick multiverse 
deb-src http://old-releases.ubuntu.com/ubuntu/ maverick multiverse 
deb http://old-releases.ubuntu.com/ubuntu/ maverick-updates multiverse 
deb-src http://old-releases.ubuntu.com/ubuntu/ maverick-updates multiverse 
  
## Uncomment the following two lines to add software from the 'backports' 
## repository. 
## N.B. software from this repository may not have been tested as 
## extensively as that contained in the main release, although it includes 
## newer versions of some applications which may provide useful features. 
## Also, please note that software in backports WILL NOT receive any review 
## or updates from the Ubuntu security team. 
# deb http://us.old-releases.ubuntu.com/ubuntu/ maverick-backports main restricted universe multiverse 
# deb-src http://us.old-releases.ubuntu.com/ubuntu/ maverick-backports main restricted universe multiverse 

2.sudo apt-get update 更新源列表信息
可以在運行“sudo apt-get update ”時查看一下錯誤信息,把不能連接的源刪除再重新運行“sudo apt-get update ”。

3.sudo apt-get upgrade 升級
或者用ubuntu自帶的更新管理器升級也可

二、安裝jdk

1、執行:sudo gedit /etc/apt/sources.lis。打開源列表,在最後一行添加

deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse 

2、保存退出。

3、更新apt源sudo apt-get update

4、安裝sun-java6-jdksudo apt-get install sun-java6-jdk

三、Android 源碼的獲取

要想獲取android源碼需要藉助於幾個軟件,下面進行一次介紹:

1、ubuntu GIT 安裝與使

$sudo apt-get install git
$sudo apt-get install git-core

通過命令更新版本庫

git clone git://git.kernel.org/pub/scm/git/git.git

2、安裝curl

$sudo apt-get install curl

3、獲取repo

按照說明,執行:

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo"> ~/bin/repo

下面就是修改它的屬性:

$ chmod a+x ~/bin/repo
$ PATH=~/bin:$PATH

4、開始下載android源碼

首先執行:

$ repo init -u https://android.googlesource.com/platform/manifest

然後再執行:

$ repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.3_r1 

這個執行完了會有要求你輸入姓名和郵箱的,但是郵箱一定是谷歌的就行,不過不用輸入郵箱和密碼也可以,直接按下Enter鍵就行。

然後創建目錄用於存放下載下來的android源碼:

$ mkdir Andriod
$ cd Andriod
$ repo init -u git://codeaurora.org/platform/manifest.git -b gingerbread

最後就是在線拉取android源碼了:

$ repo sync

嗯,如果已經開始進行下載了,表示已經順利的開始下載android源碼了。這個過程非常漫長,需要等待好長時間,大家慢慢等待吧,等待的過程中大家可以去做點其他的事情,然後就是慢慢等待吧!

當android源碼下載完成後,就會在android目錄下出現一些文件,對了,在下載的過程中,可能看不到那些文件,等下載完成後就會出現源碼目錄。以下是android源碼的目錄結構:

|-- Makefile 
|-- bionic                        (bionic C庫) 
|-- bootable                (啓動引導相關代碼) 
|-- build                        (存放系統編譯規則及generic等基礎開發包配置) 
|-- cts                        (Android兼容性測試套件標準) 
|-- dalvik                        (dalvik JAVA虛擬機) 
|-- development        (應用程序開發相關) 
|-- external                (android使用的一些開源的模組) 
|-- frameworks                (核心框架——java及C++語言) 
|-- hardware                (部分廠家開源的硬解適配層HAL代碼) 
|-- out                        (編譯完成後的代碼輸出與此目錄) 
|-- packages                (應用程序包) 
|-- prebuilt                (x86和arm架構下預編譯的一些資源) 
|-- sdk                        (sdk及模擬器) 
|-- system                        (底層文件系統庫、應用及組件——C語言) 
`-- vendor                (廠商定製代碼) 

bionic 目錄 
|-- libc                        (C庫) 
|   |-- arch-arm        (ARM架構,包含系統調用匯編實現) 
|   |-- arch-x86        (x86架構,包含系統調用匯編實現) 
|   |-- bionic                (由C實現的功能,架構無關) 
|   |-- docs                (文檔) 
|   |-- include                (頭文件) 
|   |-- inet                (?inet相關,具體作用不明) 
|   |-- kernel                (Linux內核中的一些頭文件) 
|   |-- netbsd                (?nesbsd系統相關,具體作用不明) 
|   |-- private                (?一些私有的頭文件) 
|   |-- stdio                (stdio實現) 
|   |-- stdlib                (stdlib實現) 
|   |-- string                (string函數實現) 
|   |-- tools                (幾個工具) 
|   |-- tzcode                (時區相關代碼) 
|   |-- unistd                (unistd實現) 
|   `-- zoneinfo        (時區信息) 
|-- libdl                        (libdl實現,dl是動態鏈接,提供訪問動態鏈接庫的功能) 
|-- libm                        (libm數學庫的實現,) 
|   |-- alpha                (apaha架構) 
|   |-- amd64                (amd64架構) 
|   |-- arm                (arm架構) 
|   |-- bsdsrc                (?bsd的源碼) 
|   |-- i386                (i386架構) 
|   |-- i387                (i387架構?) 
|   |-- ia64                (ia64架構) 
|   |-- include                (頭文件) 
|   |-- man                (數學函數,後綴名爲.3,一些爲freeBSD的庫文件) 
|   |-- powerpc        (powerpc架構) 
|   |-- sparc64                (sparc64架構) 
|   `-- src                (源代碼) 
|-- libstdc++                (libstdc++ C++實現庫) 
|   |-- include                (頭文件) 
|   `-- src                (源碼) 
|-- libthread_db        (多線程程序的調試器庫) 
|   `-- include                (頭文件) 
`-- linker                        (動態鏈接器) 
`-- arch                (支持arm和x86兩種架構) 

bootable 目錄 
. 
|-- bootloader                                (適合各種bootloader的通用代碼) 
|   `-- legacy                                (估計不能直接使用,可以參考) 
|       |-- arch_armv6                (V6架構,幾個簡單的彙編文件) 
|       |-- arch_msm7k                (高通7k處理器架構的幾個基本驅動) 
|       |-- include                        (通用頭文件和高通7k架構頭文件) 
|       |-- libboot                        (啓動庫,都寫得很簡單) 
|       |-- libc                        (一些常用的c函數) 
|       |-- nandwrite                (nandwirte函數實現) 
|       `-- usbloader                (usbloader實現) 
|-- diskinstaller                        (android鏡像打包器,x86可生產iso) 
`-- recovery                                (系統恢復相關) 
    |-- edify                                (升級腳本使用的edify腳本語言) 
    |-- etc                                (init.rc恢復腳本) 
    |-- minui                                (一個簡單的UI) 
    |-- minzip                                (一個簡單的壓縮工具) 
    |-- mtdutils                        (mtd工具) 
    |-- res                                (資源) 
    |   `-- images                        (一些圖片) 
    |-- tools                                (工具) 
    |   `-- ota                        (OTA Over The Air Updates升級工具) 
`-- updater                        (升級器) 

build目錄 
. 
|-- core                                (核心編譯規則) 
|-- history                                (歷史記錄) 
|-- libs                                
|   `-- host                        (主機端庫,有android “cp”功能替換) 
|-- target                                (目標機編譯對象) 
|   |-- board                        (開發平臺) 
|   |   |-- emulator        (模擬器) 
|   |   |-- generic                (通用) 
|   |   |-- idea6410        (自己添加的) 
|   |   `-- sim                (最簡單) 
|   `-- product                (開發平臺對應的編譯規則) 
|       `-- security        (密鑰相關) 
`-- tools                                (編譯中主機使用的工具及腳本) 
    |-- acp                        (Android "acp" Command) 
    |-- apicheck                (api檢查工具) 
    |-- applypatch                (補丁工具) 
    |-- apriori                        (預鏈接工具) 
    |-- atree                        (tree工具) 
    |-- bin2asm                (bin轉換爲asm工具) 
    |-- check_prereq        (檢查編譯時間戳工具) 
    |-- dexpreopt                (模擬器相關工具,具體功能不明) 
    |-- droiddoc                (?作用不明,java語言,網上有人說和JDK5有關) 
    |-- fs_config                (This program takes a list of files and directories) 
    |-- fs_get_stats                (獲取文件系統狀態) 
    |-- iself                        (判斷是否ELF格式) 
    |-- isprelinked                (判斷是否prelinked) 
    |-- kcm                        (按鍵相關) 
    |-- lsd                        (List symbol dependencies) 
    |-- releasetools                (生成鏡像的工具及腳本) 
    |-- rgb2565                (rgb轉換爲565) 
    |-- signapk                (apk簽名工具) 
    |-- soslim                        (strip工具) 
`-- zipalign                (zip archive alignment tool) 

dalvik目錄 dalvik虛擬機 
. 
|-- dalvikvm                        (main.c的目錄) 
|-- dexdump                        (dex反彙編) 
|-- dexlist                                (List all methods in all concrete classes in a DEX file.) 
|-- dexopt                                (預驗證與優化) 
|-- docs                                (文檔) 
|-- dvz                                (和zygote相關的一個命令) 
|-- dx                                (dx工具,將多個java轉換爲dex) 
|-- hit                                (?java語言寫成) 
|-- libcore                                (核心庫) 
|-- libcore-disabled                (?禁用的庫) 
|-- libdex                                (dex的庫) 
|-- libnativehelper                (Support functions for Android's class libraries) 
|-- tests                                (測試代碼) 
|-- tools                                (工具) 
`-- vm                                (虛擬機實現) 

development 目錄                (開發者需要的一些例程及工具) 
|-- apps                                (一些核心應用程序) 
|   |-- BluetoothDebug        (藍牙調試程序) 
|   |-- CustomLocale        (自定義區域設置) 
|   |-- Development        (開發) 
|   |-- Fallback                (和語言相關的一個程序) 
|   |-- FontLab                (字庫) 
|   |-- GestureBuilder        (手勢動作) 
|   |-- NinePatchLab        (?) 
|   |-- OBJViewer                (OBJ查看器) 
|   |-- SdkSetup                (SDK安裝器) 
|   |-- SpareParts                (高級設置) 
|   |-- Term                        (遠程登錄) 
|   `-- launchperf                (?) 
|-- build                                (編譯腳本模板) 
|-- cmds                                (有個monkey工具) 
|-- data                                (配置數據) 
|-- docs                                (文檔) 
|-- host                                (主機端USB驅動等) 
|-- ide                                (集成開發環境) 
|-- ndk                                (本地開發套件——c語言開發套件) 
|-- pdk                                (Plug Development Kit) 
|-- samples                        (例程) 
|   |-- AliasActivity        (?) 
|   |-- ApiDemos                (API演示程序) 
|   |-- BluetoothChat        (藍牙聊天) 
|   |-- BrowserPlugin        (瀏覽器插件) 
|   |-- BusinessCard        (商業卡) 
|   |-- Compass                (指南針) 
|   |-- ContactManager        (聯繫人管理器) 
|   |-- CubeLiveWallpaper        (動態壁紙的一個簡單例程) 
|   |-- FixedGridLayout        (像是佈局) 
|   |-- GlobalTime                (全球時間) 
|   |-- HelloActivity        (Hello) 
|   |-- Home                        (Home) 
|   |-- JetBoy                        (jetBoy遊戲) 
|   |-- LunarLander        (貌似又是一個遊戲) 
|   |-- MailSync                (郵件同步) 
|   |-- MultiResolution        (多分辨率) 
|   |-- MySampleRss        (RSS) 
|   |-- NotePad                (記事本) 
|   |-- RSSReader                (RSS閱讀器) 
|   |-- SearchableDictionary        (目錄搜索) 
|   |-- SimpleJNI                (JNI例程) 
|   |-- SkeletonApp        (空殼APP) 
|   |-- Snake                        (snake程序) 
|   |-- SoftKeyboard        (軟鍵盤) 
|   |-- Wiktionary                (?維基) 
|   `-- WiktionarySimple(?維基例程) 
|-- scripts                                (腳本) 
|-- sdk                                (sdk配置) 
|-- simulator                        (?模擬器) 
|-- testrunner                        (?測試用) 
`-- tools                                (一些工具) 

external 目錄 
. 
|-- aes                        (AES加密) 
|-- apache-http                (網頁服務器) 
|-- astl                        (ASTL (Android STL) is a slimmed-down version of the regular C++ STL.) 
|-- bison                        (自動生成語法分析器,將無關文法轉換成C、C++) 
|-- blktrace                (blktrace is a block layer IO tracing mechanism) 
|-- bluetooth                (藍牙相關、協議棧) 
|-- bsdiff                        (diff工具) 
|-- bzip2                        (壓縮工具) 
|-- clearsilver                (html模板系統) 
|-- dbus                        (低延時、低開銷、高可用性的IPC機制) 
|-- dhcpcd                (DHCP服務) 
|-- dosfstools                (DOS文件系統工具) 
|-- dropbear                (SSH2的server) 
|-- e2fsprogs                (EXT2文件系統工具) 
|-- elfcopy                (複製ELF的工具) 
|-- elfutils                        (ELF工具) 
|-- embunit                (Embedded Unit Project) 
|-- emma                        (java代碼覆蓋率統計工具) 
|-- esd                        (Enlightened Sound Daemon,將多種音頻流混合在一個設備上播放) 
|-- expat                        (Expat is a stream-oriented XML parser.) 
|-- fdlibm                        (FDLIBM (Freely Distributable LIBM)) 
|-- freetype                (字體) 
|-- fsck_msdos                (dos文件系統檢查工具) 
|-- gdata                        (google的無線數據相關) 
|-- genext2fs                (genext2fs generates an ext2 filesystem as a normal (non-root) user) 
|-- giflib                        (gif庫) 
|-- googleclient        (google用戶庫) 
|-- grub                        (This is GNU GRUB, the GRand Unified Bootloader.) 
|-- gtest                        (Google C++ Testing Framework) 
|-- icu4c                        (ICU(International Component for Unicode)在C/C++下的版本) 
|-- ipsec-tools                (This package provides a way to use the native IPsec functionality ) 
|-- iptables                (防火牆) 
|-- jdiff                        (generate a report describing the difference between two public Java APIs.) 
|-- jhead                        (jpeg頭部信息工具) 
|-- jpeg                        (jpeg庫) 
|-- junit                        (JUnit是一個Java語言的單元測試框架) 
|-- kernel-headers        (內核的一些頭文件) 
|-- libffi                        (libffi is a foreign function interface library.) 
|-- libpcap                (網絡數據包捕獲函數) 
|-- libpng                        (png庫) 
|-- libxml2                (xml解析庫) 
|-- mtpd                        (一個命令) 
|-- netcat                        (simple Unix utility which reads and writes dataacross network connections) 
|-- netperf                        (網絡性能測量工具) 
|-- neven                        (看代碼和JNI相關) 
|-- opencore                (多媒體框架) 
|-- openssl                (SSL加密相關) 
|-- openvpn                (VPN開源庫) 
|-- oprofile                (OProfile是Linux內核支持的一種性能分析機制。) 
|-- ping                        (ping命令) 
|-- ppp                        (pppd撥號命令,好像還沒有chat) 
|-- proguard                (Java class file shrinker, optimizer, obfuscator, and preverifier) 
|-- protobuf                (a flexible, efficient, automated mechanism for serializing structured data) 
|-- qemu                        (arm模擬器) 
|-- safe-iop                (functions for performing safe integer operations ) 
|-- skia                        (skia圖形引擎) 
|-- sonivox                (sole MIDI solution for Google Android Mobile Phone Platform) 
|-- speex                        (Speex編/解碼API的使用(libspeex)) 
|-- sqlite                        (數據庫) 
|-- srec                        (Nuance 公司提供的開源連續非特定人語音識別) 
|-- strace                        (trace工具) 
|-- svox                        (Embedded Text-to-Speech) 
|-- tagsoup                (TagSoup是一個Java開發符合SAX的HTML解析器) 
|-- tcpdump                (抓TCP包的軟件) 
|-- tesseract                (Tesseract Open Source OCR Engine.) 
|-- tinyxml                (TinyXml is a simple, small, C++ XML parser) 
|-- tremor                        (I stream and file decoder provides an embeddable,integer-only library) 
|-- webkit                        (瀏覽器核心) 
|-- wpa_supplicant        (無線網卡管理) 
|-- xmlwriter                (XML 編輯工具) 
|-- yaffs2                        (yaffs文件系統) 
`-- zlib                        (a general purpose data compression library) 

frameworks 目錄        (核心框架——java及C++語言) 
. 
|-- base                        (基本內容) 
|   |-- api                  (?都是xml文件,定義了java的api?) 
|   |-- awt                 (AWT庫) 
|   |-- build                (空的) 
|   |-- camera           (攝像頭服務程序庫) 
|   |-- cmds              (重要命令:am、app_proce等) 
|   |-- core                (核心庫) 
|   |-- data                (字體和聲音等數據文件) 
|   |-- docs                (文檔) 
|   |-- graphics           (圖形相關) 
|   |-- include             (頭文件) 
|   |-- keystore        (和數據簽名證書相關) 
|   |-- libs                (庫) 
|   |-- location        (地區庫) 
|   |-- media                (媒體相關庫) 
|   |-- obex                (藍牙傳輸庫) 
|   |-- opengl                (2D-3D加速庫) 
|   |-- packages        (設置、TTS、VPN程序) 
|   |-- sax                (XML解析器) 
|   |-- services        (各種服務程序) 
|   |-- telephony        (電話通訊管理) 
|   |-- test-runner        (測試工具相關) 
|   |-- tests                (各種測試) 
|   |-- tools                (一些叫不上名的工具) 
|   |-- vpn                (VPN) 
|   `-- wifi                (無線網絡) 
|-- opt                        (可選部分) 
|   |-- com.google.android                                (有個framework.jar) 
|   |-- com.google.android.googlelogin                (有個client.jar) 
|   `-- emoji                (standard message elements) 
`-- policies                (Product policies are operating system directions aimed at specific uses) 
    `-- base                
        |-- mid        (MID設備) 
        `-- phone   (手機類設備一般用這個,與鎖屏有關的代碼) 

hardware 目錄                (部分廠家開源的硬解適配層HAL代碼) 
|-- broadcom                        (博通公司) 
|   `-- wlan                        (無線網卡) 
|-- libhardware                        (硬件庫) 
|   |-- include                        (頭文件) 
|   `-- modules                (Default (and possibly architecture dependents) HAL modules) 
|       |-- gralloc                (gralloc顯示相關) 
|       `-- overlay                (Skeleton for the "overlay" HAL module.) 
|-- libhardware_legacy        (舊的硬件庫) 
|   |-- flashlight                (背光) 
|   |-- gps                        (GPS) 
|   |-- include                        (頭文件) 
|   |-- mount                        (舊的掛載器) 
|   |-- power                        (電源) 
|   |-- qemu                        (模擬器) 
|   |-- qemu_tracing        (模擬器跟蹤) 
|   |-- tests                        (測試) 
|   |-- uevent                        (uevent) 
|   |-- vibrator                        (震動) 
|   `-- wifi                        (無線) 
|-- msm7k                        (高通7k處理器開源抽象層) 
|   |-- boot                        (啓動) 
|   |-- libaudio                (聲音庫) 
|   |-- libaudio-qsd8k        (qsd8k的聲音相關庫) 
|   |-- libcamera                (攝像頭庫) 
|   |-- libcopybit                (copybit庫) 
|   |-- libgralloc                (gralloc庫) 
|   |-- libgralloc-qsd8k        (qsd8k的gralloc庫) 
|   |-- liblights                (背光庫) 
|   `-- librpc                        (RPC庫) 
|-- ril                                (無線電抽象層) 
|   |-- include                        (頭文件) 
|   |-- libril                        (庫) 
|   |-- reference-cdma-sms        (cdma短信參考) 
|   |-- reference-ril                        (ril參考) 
|   `-- rild                                (ril後臺服務程序) 
`-- ti                                                (ti公司開源HAL) 
    |-- omap3                                (omap3處理器) 
    |   |-- dspbridge                (DSP橋) 
    |   |-- libopencorehw        (opencore硬件庫) 
    |   |-- liboverlay                (overlay硬件庫) 
    |   |-- libstagefrighthw        (stagefright硬件庫) 
    |   `-- omx                        (omx組件) 
    `-- wlan                                (無線網卡) 

packages 目錄 
. 
|-- apps                            (應用程序庫) 
|   |-- AlarmClock              (鬧鐘) 
|   |-- Bluetooth                (藍牙) 
|   |-- Browser                  (瀏覽器) 
|   |-- Calculator                (計算器) 
|   |-- Calendar                  (日曆) 
|   |-- Camera                   (相機) 
|   |-- CertInstaller             (在Android中安裝數字簽名,被調用) 
|   |-- Contacts                 (撥號(調用)、聯繫人、通話記錄) 
|   |-- DeskClock               (桌面時鐘) 
|   |-- Email                       (Email) 
|   |-- Gallery                     (相冊,和Camera類似,多了列表) 
|   |-- Gallery3D                 (?3D相冊) 
|   |-- GlobalSearch            (爲google搜索服務,提供底層應用) 
|   |-- GoogleSearch           (google搜索) 
|   |-- HTMLViewer             (瀏覽器附屬界面,被瀏覽器應用調用,同時提供存儲記錄功能) 
|   |-- IM                            (即時通訊,爲手機提供信號發送、接收、通信的服務) 
|   |-- Launcher                  (登陸啓動項,顯示圖片框架等等圖形界面) 
|   |-- Launcher2                (登陸啓動項,負責應用的調用) 
|   |-- Mms                        (?彩信業務) 
|   |-- Music                        (音樂播放器) 
|   |-- PackageInstaller        (安裝、卸載程序的響應) 
|   |-- Phone                        (電話撥號程序) 
|   |-- Provision                (預設應用的狀態,使能應用) 
|   |-- Settings                (開機設定,包括電量、藍牙、設備信息、界面、wifi等) 
|   |-- SoundRecorder        (錄音機,可計算存儲所需空間和時間) 
|   |-- Stk                         (接收和發送短信) 
|   |-- Sync                        (空)   -------○1 
|   |-- Updater                (空) 
|   `-- VoiceDialer                (語音識別通話) 
|-- inputmethods                (輸入法) 
|   |-- LatinIME                (拉丁文輸入法) 
|   |-- OpenWnn                (OpenWnn輸入法) 
|   `-- PinyinIME                (拼音輸入法) 
|-- providers                        (提供器,提供應用程序、界面所需的數據) 
|   |-- ApplicationsProvider                (應用程序提供器,提供應用程序啓動項、更新等) 
|   |-- CalendarProvider                        (日曆提供器) 
|   |-- ContactsProvider                        (聯繫人提供器) 
|   |-- DownloadProvider                (下載管理提供器) 
|   |-- DrmProvider                        (創建和更新數據庫時調用) 
|   |-- GoogleContactsProvider        (聯繫人提供器的子類,用以同步聯繫人) 
|   |-- GoogleSubscribedFeedsProvider(設置信息提供器) 
|   |-- ImProvider                                (空) 
|   |-- ManagementProvider                (空) 
|   |-- MediaProvider                        (媒體提供器,提供存儲數據) 
|   |-- TelephonyProvider                (彩信提供器) 
|   |-- UserDictionaryProvider        (用戶字典提供器,提供用戶常用字字典) 
|   `-- WebSearchProvider                (空) 
|-- services                                        
|   |-- EasService                                (空) 
|   `-- LockAndWipe                        (空) 
`-- wallpapers                                        (牆紙) 
    |-- Basic                                        (基本牆紙,系統內置牆紙) 
    |-- LivePicker                                (選擇動態壁紙) 
    |-- MagicSmoke                        (壁紙特殊效果) 
    `-- MusicVisualization                (音樂可視化,圖形隨音樂而變化) 

○1裏面有一個隱藏的.git文件夾,內容都是一樣的,沒有有意義的代碼,config看似乎是一個下載程序,因此認爲這些文件夾下沒有實質東西。 

prebuilt 目錄                        (x86和arm架構下預編譯的一些資源) 
. 
|-- android-arm                (arm-android相關) 
|   |-- gdbserver                (gdb調試器) 
|   `-- kernel                        (模擬的arm內核) 
|-- android-x86                (x86-android相關) 
|   `-- kernel                        (空的) 
|-- common                        (通用編譯好的代碼,應該是java的) 
|-- darwin-x86                        (drawin x86平臺) 
|   `-- toolchain                (工具鏈) 
|       |-- arm-eabi-4.2.1        
|       |-- arm-eabi-4.3.1        
|       `-- arm-eabi-4.4.0        
|-- darwin-x86_64                (drawin x86 64bit平臺) 
|-- linux-x86                        (linux x86平臺) 
|   `-- toolchain                (工具鏈,我們應該主要用這個) 
|       |-- arm-eabi-4.2.1        
|       |-- arm-eabi-4.3.1        
|       |-- arm-eabi-4.4.0        
|       `-- i686-unknown-linux-gnu-4.2.1        (x86版編譯器) 
|-- linux-x86_64                (linux x86 64bit平臺) 
|-- windows                        (windows平臺) 
`-- windows-x86_64        (64bit windows平臺) 
system 目錄                (底層文件系統庫、應用及組件——C語言) 
. 
|-- Bluetooth                (藍牙相關) 
|-- core                        (系統核心工具盒接口) 
|   |-- adb                (adb調試工具) 
|   |-- cpio                (cpio工具,創建img) 
|   |-- debuggerd        (調試工具) 
|   |-- fastboot        (快速啓動相關) 
|   |-- include                (系統接口頭文件) 
|   |-- init                (init程序源代碼) 
|   |-- libacc                (輕量級C編譯器) 
|   |-- libctest                (libc測試相關) 
|   |-- libcutils        (libc工具) 
|   |-- liblog                (log庫) 
|   |-- libmincrypt        (加密庫) 
|   |-- libnetutils        (網絡工具庫) 
|   |-- libpixelflinger        (圖形處理庫) 
|   |-- libsysutils        (系統工具庫) 
|   |-- libzipfile        (zip庫) 
|   |-- logcat                (查看log工具) 
|   |-- logwrapper        (log封裝工具) 
|   |-- mkbootimg        (製作啓動boot.img的工具盒腳本) 
|   |-- netcfg                (網絡配置netcfg源碼) 
|   |-- nexus                (google最新手機的代碼) 
|   |-- rootdir                (rootfs,包含一些etc下的腳本和配置) 
|   |-- sh                        (shell代碼) 
|   |-- toolbox                (toolbox,類似busybox的工具集) 
|   `-- vold                (SD卡管理器) 
|-- extras                        (額外工具) 
|   |-- latencytop        (a tool for software developers ,identifying system latency happen) 
|   |-- libpagemap        (pagemap庫) 
|   |-- librank                (Java Library Ranking System庫) 
|   |-- procmem        (pagemap相關) 
|   |-- procrank        (Java Library Ranking System相關) 
|   |-- showmap        (showmap工具) 
|   |-- showslab        (showslab工具) 
|   |-- sound                (聲音相關) 
|   |-- su                        (su命令源碼) 
|   |-- tests                (一些測試工具) 
|   `-- timeinfo        (時區相關) 
`-- wlan                        (無線相關) 
    `-- ti                        (ti網卡相關工具及庫) 


vendor 目錄                        (廠家定製內容) 

|-- aosp                             (android open source project) 
|   `-- products                  (一些板級規則) 
|-- htc                               (HTC公司) 
|   |-- common-open         (通用部分) 
|   |   `-- akmd                 (解壓img用的工具) 
|   |-- dream-open            (G1開放部分) 
|   |-- prebuilt-open           (預編譯開放部分) 
|   `-- sapphire-open         (sapphire這款型號開放內容) 
|-- pv-open                       (沒東西) 
|-- qcom                           (裏面基本是空的) 
`-- sample                        (google提供的樣例) 
    |-- apps                        (應用) 
    |   |-- client                   (用戶) 
    |   `-- upgrade              (升級) 
    |-- frameworks             (框架) 
    |   `-- PlatformLibrary   (平臺庫) 
    |-- products                  (產品) 
    |-- sdk_addon              (sdk添加部分) 
    `-- skins                       (皮膚) 

        `-- WVGAMedDpi      (WVGA適用的圖片)

 

四、Android 源碼的編譯(make)

源碼下載完成後接下來就是對源碼的編譯了,下載好源碼後,會在android目錄下有一個MakeFile文件,然後直接在終端下輸入make既可以對android源碼進行編譯,在編譯的過程中依然會出現很多的錯誤,接下來,參照網上給出的一些錯誤和解決方法:

1、/usr/bin/ld: cannot find -lz

host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1
解決方法: sudo apt-get install zlib1g-dev    sudo apt-get install lib64z1-dev

2、/bin/bash: bison: command not found

Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y
bison -d  -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
/bin/bash: bison: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127
解決方法:sudo apt-get install bison

 

3、/bin/bash: flex: command not found

out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp: In function ‘int yyparse()’:
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1827: warning: deprecated conversion from string constant to ‘char*’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1970: warning: deprecated conversion from string constant to ‘char*’
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
/bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
解決方法: sudo apt-get install flex

 

4、/usr/bin/ld: cannot find -lncurses

host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1

解決方法:sudo apt-get install libncurses5-dev

 

5、fatal error: GL/glx.h: No such file or directory

development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 1

解決方法:sudo apt-get install libgl1-mesa-dev

 

6、sh: gperf: not found

target Generated: libwebcore <= external/webkit/Source/JavaScriptCore/create_regex_tables
Generating CSSPropertyNames.h <= CSSPropertyNames.in
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 140.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h'

解決方法:sudo apt-get install gperf

五、編譯SDK

編譯SDK可以得到與源碼同步的SDK,還會生成一些tools,在源碼根目錄下:

$ sudo make PRODUCT-sdk-sdk

編譯生成的SDK在out/host/linux-x86/SDK下。之後如果在ubuntu下使用eclipse進行開發,可以使用你編譯的SDK。

下面就在模擬器中運行鏡像,建議切到root用戶下,首先配置幾個環境變量,將自己編譯的SDK設爲優先級最高,在源碼根目錄下執行:

$ update-alternatives --install /usr/bin/AndroidSDK AndroidSDK ./out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86 255

這樣會在/etc/alternatives下生成一個指向該SDK目錄的軟連接AndroidSDK,這個目錄主要存放一些系統默認打開的程序的信息和配置。那麼/usr/bin/AndroidSDK就指向這個軟連接。接着執行:

$ gedit ~/.bashrc

在文件末尾添加:

export ANDROID_SDK_HOME=/usr/bin/AndroidSDK
export PATH=$ANDROID_SDK_HOME/tools:$PATH
export ANDROID_PRODUCT_OUT=~/android/out/target/product/generic

接着就可以執行:

$ emulator

運行的就是你編譯的映像。執行emulator 命令時,如果不帶任何參數,則Linux Kernel鏡像默認使用~/Android/prebuilt/android-arm/kernel目錄下的kernel-qemu文件,而

Android鏡像文件則默認使用ANDROID_PRODUCT_OUT目錄下的system.img、userdata.img和ramdisk.img。模擬器運行需要這四個文件,如果你編譯了內核則可以使用自己的Kernel鏡像,可用於android移植等。

六、單獨編譯模塊

如果你不想編譯整個系統,就想編譯某一個應用程序,可以使用mmm命令,使用之前,在源碼目錄下先要執行:

$ build/envsetup.sh

這樣會生成一些命令,有m即make、mm編譯當前目錄下所有模塊、mmm編譯指定目錄下所有模塊。你可以把packages/apps/Music應用的application name改成MyMusic(AndroidManifest.xml中),然後執行:

$ mmm packages/apps/Music

在out/target/product/generic/system/app中就可以看見Music.apk,然後執行:

$ make snod

重新生成system.img。

以上僅僅只是我個人遇到的問題,然後在網上查找資料解決後,運行成功,如果遇到其他問題,可以在網上尋找其他的解決辦法,另外可以參考官網:

http://source.android.com/source/initializing.html



 


 


 


 


 


 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章