搭建Android源碼編譯環境

來源:互聯網
上載者:User

1.安裝Ubuntu 10.10
      可選擇使用Wubi安裝。

2.安裝Python
      Ubuntu 10.10 已經安裝了2.6版。

3.安裝JDK
      更新軟體庫:
      sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
      sudo apt-get update
      下載JDK:
      使用新立得軟體包管理器下載 sun-java6-jdk或執行命令:sudo apt-get install sun-java6-jdk
      修改當前使用的JDK版本:sudo update-alternatives --config java

4.安裝所需的組件
      To set up your development environment, install the following required packages:
      執行命令:sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

      For building Froyo or an older release on a 64-bit system, several other packages are necessary to establish a 32-bit build  environment:
      執行命令:sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386

5.安裝幾個必須庫
      進入新立得軟體包管理器勾選lib32z1-dev、zlib-bin並安裝。

6.Android編譯需要安裝mtd-utils(該程式不能升級,使用指定版本mtd-utils_20090606-1_amd64.deb)
      使用強制安裝方式:sudo dpkg -i 檔案名稱
      此組件是用來建立UBI檔案系統的。

7.安裝GCC編譯器
      系統已經預設安裝了4.4.5版。

8.安裝交叉編譯工具arm-linux-gcc(PAO的預設配置為源碼放在主資料夾的project下,arm-linux-gcc放在project的tools下)
      A.解壓arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz,執行命令:
         tar xvzf arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz –C home/administrator/project/tools/
         cp -r home/administrator/project/tools/opt/FriendlyARM/toolschain/4.5.1 /home/administrator/project/tools/arm-linux-4.5.1/
         rm -rf home/administrator/project/tools/opt
      B.設定環境變數(多個變數時用“:”分格):
             sudo gedit /etc/profile
             在最後添加:PATH=$PATH:/home/administrator/project/tools/arm-linux-4.5.1/bin
      C.重新登入後運行:arm-linux-gcc --v 測試是否安裝成功。

9.錯誤處理
      在Ubuntu10.10(64位)編譯Android2.3源碼時,遇到各種各樣的問題。不是缺這個,就是少那個。現把這些問題和解決方案羅列出來,供大家參考。

錯誤:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] 錯誤 1

解決:
  sudo apt-get install libc6-dev-i386

錯誤:
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp] error 1

解決:
  sudo apt-get install g++-multilib

錯誤:
external/clearsilver/cgi/cgi.c:22: fatal error: zlib.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1

解決:
sudo apt-get install zlib1g-dev

錯誤:
/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 lib32z1-dev

錯誤:
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

錯誤:
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

錯誤:
/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 lib32ncurses5-dev

錯誤:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/main-common.o] Error 1

解決:
sudo apt-get install libx11-dev

錯誤:
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 96.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h'

解決:
sudo apt-get install gperf

錯誤:
build/core/java.mk:9: *** bin: Target java module does not define any source or resource files. Stop.

解決:
      刪除源碼根目錄下的bin檔案夾,這個檔案夾是匯入eclipse時建立的。

10.相關資料
      A.http://source.android.com/source/initializing.html;

      B.mini6410使用者手冊。

轉自:http://www.cnblogs.com/jvlstudio/archive/2011/05/14/2046562.html

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.