編譯android源碼

來源:互聯網
上載者:User

首先搭建android編譯環境。

      (一)安裝配置java5

      1 先安裝java6(編譯android需要java5,此處為推薦)

         開啟終端,執行以下命令,或使用Adept/新立得軟體管理器,在其中分別搜尋"sun-java6-jre"和"sun-java6-jdk"並標記安裝。 

         sudo apt-get install sun-java6-jre
         如果空間富裕,建議安裝一個JDK。

         sudo apt-get install sun-java6-jdk
         提示:安裝過程中需要你回答是否同意使用協議(終端中紅藍色的提示介面),此時按tab鍵至OK,再按斷行符號即可正常安裝。

      2 安裝java5

        

      如果是ubuntu910版本,安裝java5時需要更新源,方法:

         將下面更新放到更新源最前面
          更新的源:sudo gedit /etc/apt/sources.list
      deb http://cn.archive.ubuntu.com/ubuntu/ jaunty multiverse
      deb http://cn.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse

 

      sudo apt-get install sun-java5-jre

       sudo apt-get install sun-java5-jdk 

      3 設定當前預設的java解譯器和編譯器: (ubuntu9.10如果沒有安裝多個java虛擬機器的話可以跳過這一步。)

         sudo update-alternatives --config java
         執行後會出現類似如下的畫面:

There are 2 alternatives which provide `java'.

Selection Alternative
-----------------------------------------------
+        1    /usr/lib/jvm/java-6-openjdk/jre/bin/java
          2    /usr/lib/jvm/java-6-sun/jre/bin/java
*         3    /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
Press enter to keep the default[*], or type selection number:

輸入 有包含 "sun" 的行的前面的數字。如上面顯示,則輸入3,然後斷行符號確定。(編譯android需要配置java5)

sudo update-alternatives --config javac

操作和前面類似。

       4 配置JAVA環境變數:

     sudo gedit /etc/environment

        在其中添加如下兩行:

     JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
     ANDROID_JAVA_HOME=$JAVA_HOME
     CLASSPATH=.:/usr/lib/jvm/java-1.5.0-sun/lib

        要使配置生效必須重啟機器或者在命令列輸入

     . /etc/environment

       5 配置JVM的優先順序: (ubuntu9.10如果沒有安裝多個java虛擬機器的話可以跳過這一步。)

     sudo gedit /etc/jvm

        將檔案中的

     /usr/lib/jvm/java-1.5.0-sun

        這一行填入到配置塊的頂部

 

 (二)安裝交叉編譯器及其他編譯工具

 

1.1.1       FLEX

Flex is a tool for generating scanners.

# sudo apt-get install flex

1.1.2       BISON

Bison is a general-purpose parser generator.

       # sudo apt-get install bison

 

1.1.3       gperf

gperf is a program that generates perfect hash functions.

       # sudo apt-get install gperf

 

1.1.4       libsdl-dev

SDL is a library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard.

       # sudo apt-get install libsdl-dev

1.1.5       libesd0-devl

This program is designed to mix together several digitized audio streams for playback by a single device.

       # sudo apt-get install libesd0-dev

 

1.1.6       libwxgtk2.6-dev

This package provides files needed to compile wxWidgets programs.

# sudo apt-get install libwxgtk2.6-dev

 

1.1.7       zlib1g-dev

zlib is a library implementing the deflate compression method.

       # sudo apt-get install zlib1g-dev

 

1.1.8       build-essential

This package contains an informational list of packages which are considered essential for building Debian packages.

       # sudo apt-get install build-essential

 

1.1.9       libncurses5-dev

This package contains the header files, static libraries and symbolic links.

       # sudo apt-get install libncurses5-dev

1.1.10 Uboot-mkimage

This package contains the mkimage utility.

       # sudo apt-get install uboot-mkimage

 

1.2             Cross Tool

1. Copy the cross tool package to /usr/local/arm

   If the arm directory is not exist in host pc then create the directory

       # mkdir /usr/local/arm

       # cp 4.3.1-eabi-armv6-20080707.tar.bz2 /usr/local/arm

      

2. unzip the code using tar command

       # tar xvjf 4.3.1-eabi-armv6-20080707.tar.bz2

 

3. Add source path in your environment file

# vi ~/.bashrc

Add the source path

PATH=$PATH:/usr/local/arm/4.3.1-eabi-armv6/usr/bin

# source ~/.bashrc

 

4 unzip the code using tar command

# tar xvjf cross-4.2.2-eabi.tar.bz2 -C /usr/local/arm

 

 

1.3             Build Android

1. 用tar命令將源碼解壓到某路徑下path/.     

2. Move to android directory and build it.

       # cd path/android(這個是你解壓android源碼後的路徑)

       # make(這步是編譯,可能會需要很長時間)

-------------------------------------------------------------------------------------------------------------

明天再寫如何在Eclipse下調試android源碼

 

相關文章

聯繫我們

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