Ubuntu搭建android編譯環境總結

來源:互聯網
上載者:User

Android源碼:官方下載
Android編譯版本: PLATFORM_VERSION=4.2.2
OS 作業系統平台: Linux carson-pc 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux(Ubuntu11.04  64bit)

1. 要用jdk1.6,不能用jdk1.7

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

方法:sudo apt-get install bison

3.  /bin/bash: xsltproc: command not found

方法:sudo apt-get install xsltproc

4./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

5. sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 140.

方法:sudo apt-get install gperf

6. gcc: error trying to exec 'cc1plus': execvp: No such file or directory

方法:sudo apt-get install g++

7.collect2: error: ld terminated with signal 9

方法:增加ubuntu的虛擬記憶體。具體操作如下:

setp1:查看系統虛擬記憶體,命令:free -m

 

carson@carson-pc:~$ free -m             total       used       free     shared    buffers     cachedMem:          1998       1528        469          0          6        423-/+ buffers/cache:       1098        900Swap:         2036        361       1675

我這是已經增加swap的,一般swap2G左右就足夠編譯android用的。在編譯過程中,雖然增加了2G,但在編譯時間,若做一些操作比較佔用swap的話,也會出現此問題。比如從移動硬碟copy android 源碼。

 

setp2.建立一個 Swap 檔案。

mkdir swap
cd swap  
sudo dd if=/dev/zero of=swapfile bs=1024 count=100000
出現下列提示,上面命令中的 count 即代表swap檔案大小,即增加的虛擬記憶體大小。此命令出現如下資訊

 

100000+0 records in100000+0 records out102400000 bytes (102 MB) copied, 0.377325 s, 271 MB/s

setp3:把產生的檔案轉換成 Swap 檔案
sudo mkswap swapfile

 

此命令出現如下資訊:

 

Setting up swapspace version 1, size = 99996 KiBno label, UUID=b26fe88c-11c2-40ad-8139-6e69e96b6b68

setp4:啟用 Swap 檔案。
sudo swapon swapfile

 

此時free -m 查看Swap資訊

 

             total       used       free     shared    buffers     cachedMem:          1998       1189        809          0         34        624
-/+ buffers/cache:        530       1468Swap:         2134        986       1148

至此,swap已經增加成功了,如果想卸載剛增加的swap;

 

sudo swapoff swapfile

如果需要一直保持這個 swap ,可以sudo -s換到root
然後把它寫入 /etc/fstab 檔案。
 
swapfilepath swap swap defaults 0 0

8. In file included from /usr/include/semaphore.h:22:0,
                 from cts/suite/audio_quality/lib/include/Semaphore.h:21,
                 from cts/suite/audio_quality/lib/src/Semaphore.cpp:17:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
make: In file included from /usr/include/stdlib.h:25:0,
                 from cts/suite/audio_quality/lib/src/Adb.cpp:16:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.

方法:sudo apt-get install libc6-dev:i386

     sudo apt-get install build-essential

     sudo apt-get install gcc-multilib

9./bin/sh: gcc: not found

方法:sudo apt-get install gcc,gcc是C的編譯器

10.gccgcc: error trying to exec 'cc1plus': execvp: gcc: error trying to exec 'No such file or directory

方法:sudo apt-get install g++,g++是C++的編譯器

11. /bin/bash: xmllint: command not found
方法:sudo apt-get  install libxml2-utils

未完待續

 

相關文章

聯繫我們

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