1. 程式人生 > >Android原始碼編譯環境搭建問題及解決方案小結

Android原始碼編譯環境搭建問題及解決方案小結

1. ImportError: No module named bz2 for Python 2.7.2

(1)$ source build/envsetup.sh

(2)$ lunch aosp_arm-eng

(3)$ make -j4

前兩步的執行沒有問題,第三步出現“ImportError: No module named bz2 for Python 2.7.*”之類的錯誤,具體的問題描述隨著問題解決不再出現了,所以這裡大致闡述一下問題出現的原因。(你需要大致瞭解一下Python這門語言,誰用誰知道,學過都說好!)你很有可能是從原始碼編譯python,代替了系統原來的python,但是沒有bz2

標頭檔案。
所以,解決辦法是新增bz2:
Install them on Ubuntu/Debian:

sudo apt-get install libbz2-dev

2. No command ‘emulator’ found, did you mean: Command ‘qemulator’ from package ‘qemulator’ (universe) emulator: command not found

在你完成整個Android原始碼的編譯之後,立刻啟動了模擬器(注意是立刻,你沒有進行關閉終端或是關機重啟之類的操作),使用

$ emulator

命令成功重啟了模擬器
注:模擬器會在你編譯Android的過程中被編譯出來,模擬器的路徑為:

~/Desktop/Android/out/host/linux-x86/bin

但是,
你關機之後發現再次使用emulator命令時,報錯了,你擔心是你的命令敲錯了,於是一遍又一遍地重複著,你的疑惑伴隨著Tab鍵一次次的敲擊逐漸加重,然而這不是你敲錯字母了,更不是Tab的錯,問題出在這裡:stackoverflow上關於該問題的情景描述及解答
你應該:
Set up some functions for the environment:

$ . build/envsetup.sh

You now should actually execute one of those functions to get the paths set correctly (as Pingzhong Li pointed out, this is not mentioned in the Android build instructions!):

$ set_stuff_for_environment