Android源碼編譯教程

前言

當(dāng)前環(huán)境:

1品山、Ubuntu16.04胆建,已經(jīng)安裝好了各種依賴

2、Android代碼版本肘交,android-9.0.0_r3

一笆载、導(dǎo)入環(huán)境

源碼根目錄輸入:

source build/envsetup.sh

輸出:

including device/generic/car/vendorsetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-mips64/vendorsetup.sh
including device/generic/mini-emulator-mips/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/generic/uml/vendorsetup.sh
including device/google/cuttlefish/vendorsetup.sh
including device/google/marlin/vendorsetup.sh
including device/google/muskie/vendorsetup.sh
including device/google/taimen/vendorsetup.sh
including device/linaro/hikey/vendorsetup.sh
including sdk/bash_completion/adb.bash

二、配置編譯信息

輸入:

lunch

輸入可以選擇的版本

You're building on Linux

Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_mips-eng
     4. aosp_mips64-eng
     5. aosp_x86-eng
     6. aosp_x86_64-eng
     7. aosp_car_arm-userdebug
     8. aosp_car_arm64-userdebug
     9. aosp_car_x86-userdebug
     10. aosp_car_x86_64-userdebug
     11. mini_emulator_arm64-userdebug
     12. m_e_arm-userdebug
     13. m_e_mips64-eng
     14. m_e_mips-userdebug
     15. mini_emulator_x86_64-userdebug
     16. mini_emulator_x86-userdebug
     17. uml-userdebug
     18. aosp_cf_x86_auto-userdebug
     19. aosp_cf_x86_phone-userdebug
     20. aosp_cf_x86_tablet-userdebug
     21. aosp_cf_x86_tablet_3g-userdebug
     22. aosp_cf_x86_tv-userdebug
     23. aosp_cf_x86_wear-userdebug
     24. aosp_cf_x86_64_auto-userdebug
     25. aosp_cf_x86_64_phone-userdebug
     26. aosp_cf_x86_64_tablet-userdebug
     27. aosp_cf_x86_64_tablet_3g-userdebug
     28. aosp_cf_x86_64_tv-userdebug
     29. aosp_cf_x86_64_wear-userdebug
     30. cf_x86_auto-userdebug
     31. cf_x86_phone-userdebug
     32. cf_x86_tablet-userdebug
     33. cf_x86_tablet_3g-userdebug
     34. cf_x86_tv-userdebug
     35. cf_x86_wear-userdebug
     36. cf_x86_64_auto-userdebug
     37. cf_x86_64_phone-userdebug
     38. cf_x86_64_tablet-userdebug
     39. cf_x86_64_tablet_3g-userdebug
     40. cf_x86_64_tv-userdebug
     41. cf_x86_64_wear-userdebug
     42. aosp_marlin-userdebug
     43. aosp_marlin_svelte-userdebug
     44. aosp_sailfish-userdebug
     45. aosp_walleye-userdebug
     46. aosp_walleye_test-userdebug
     47. aosp_taimen-userdebug
     48. hikey-userdebug
     49. hikey64_only-userdebug
     50. hikey960-userdebug

Which would you like? [aosp_arm-eng] #這里輸入對應(yīng)數(shù)字并回車

為了方便可以用一下方式,以aosp_arm64-eng為例:

lunch aosp_arm64-eng
# 或者
lunch 2

三凉驻、編譯代碼

輸入:

make -j4
# -j4是用4個核心數(shù)同時編譯的意思腻要,可不加,也可以根據(jù)機器實際改變數(shù)字

在不出錯的情況下涝登,漫長的等待雄家,出現(xiàn)下面情況表示編譯成功

#### build completed successfully (01:23:12 (hh:mm:ss)) ####

四、啟動Android虛擬機

在編譯成功后胀滚,根目錄輸入:

emulator

啟動成功

啟動成功

五趟济、錯誤記錄

錯誤一

[1/1] out/soong/.minibootstrap/minibp out/soong/.bootstrap/build.ninja
FAILED: out/soong/.bootstrap/build.ninja 
out/soong/.minibootstrap/minibp -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/.bootstrap/build.ninja.d -o out/soong/.bootstrap/build.ninja Android.bp
internal error: could not open symlink hardware/qcom/sm8150/Android.bp; its target (data/ipacfg-mgr/os_pickup.bp) cannot be opened
internal error: could not open symlink hardware/qcom/sdm845/Android.bp; its target (data/ipacfg-mgr/os_pickup.bp) cannot be opened
ninja: build stopped: subcommand failed.
11:02:14 soong minibootstrap failed with: exit status 1

#### failed to build some targets (13 seconds)

解:查了一下,對應(yīng)兩個bp文件都是空的蛛淋,直接刪除解決咙好。

錯誤二

[1/1] out/soong/.minibootstrap/minibp out/soong/.bootstrap/build.ninja
[55/56] glob prebuilts/ndk/stl.bp
[77/77] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
out/build-aosp_arm64-cleanspec.ninja is missing, regenerating...
out/build-aosp_arm64.ninja is missing, regenerating...
[382/936] including hardware/qcom/sdm845/Android.mk ...
hardware/qcom/power/Android.mk:3: error: hardware/qcom/sdm845/Android.mk: No such file or directory
11:10:31 ckati failed with: exit status 1

#### failed to build some targets (01:19 (mm:ss))

解:查了一下sdm845目錄下只有一個空的mk,刪除sdm845目錄解決褐荷。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末勾效,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子叛甫,更是在濱河造成了極大的恐慌层宫,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,657評論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件其监,死亡現(xiàn)場離奇詭異萌腿,居然都是意外死亡,警方通過查閱死者的電腦和手機抖苦,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,889評論 3 394
  • 文/潘曉璐 我一進店門毁菱,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人锌历,你說我怎么就攤上這事贮庞。” “怎么了究西?”我有些...
    開封第一講書人閱讀 164,057評論 0 354
  • 文/不壞的土叔 我叫張陵窗慎,是天一觀的道長。 經(jīng)常有香客問我卤材,道長遮斥,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,509評論 1 293
  • 正文 為了忘掉前任扇丛,我火速辦了婚禮术吗,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘帆精。我一直安慰自己较屿,他們只是感情好材蹬,可當(dāng)我...
    茶點故事閱讀 67,562評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著吝镣,像睡著了一般堤器。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上末贾,一...
    開封第一講書人閱讀 51,443評論 1 302
  • 那天闸溃,我揣著相機與錄音,去河邊找鬼拱撵。 笑死辉川,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的拴测。 我是一名探鬼主播乓旗,決...
    沈念sama閱讀 40,251評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼集索!你這毒婦竟也來了屿愚?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,129評論 0 276
  • 序言:老撾萬榮一對情侶失蹤务荆,失蹤者是張志新(化名)和其女友劉穎妆距,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體函匕,經(jīng)...
    沈念sama閱讀 45,561評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡娱据,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,779評論 3 335
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了盅惜。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片中剩。...
    茶點故事閱讀 39,902評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖抒寂,靈堂內(nèi)的尸體忽然破棺而出结啼,到底是詐尸還是另有隱情,我是刑警寧澤蓬推,帶...
    沈念sama閱讀 35,621評論 5 345
  • 正文 年R本政府宣布妆棒,位于F島的核電站澡腾,受9級特大地震影響沸伏,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜动分,卻給世界環(huán)境...
    茶點故事閱讀 41,220評論 3 328
  • 文/蒙蒙 一毅糟、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧澜公,春花似錦姆另、人聲如沸喇肋。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,838評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽蝶防。三九已至,卻和暖如春明吩,著一層夾襖步出監(jiān)牢的瞬間间学,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,971評論 1 269
  • 我被黑心中介騙來泰國打工印荔, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留低葫,地道東北人。 一個月前我還...
    沈念sama閱讀 48,025評論 2 370
  • 正文 我出身青樓仍律,卻偏偏與公主長得像嘿悬,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子水泉,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,843評論 2 354