歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 11.04 下載和編譯Android代碼

Ubuntu 11.04 下載和編譯Android代碼

日期:2017/2/28 16:10:32   编辑:Linux教程

最近想學習學習Android,就在自己到pc上裝了Ubuntu 11.04,然後按照www.android.com上的說明,進行操作。

不過,過程中也遇到了不少問題,在此做個總結。

第一次,是在進行到repo sync一步的時候,本來想避開網絡高負載時段,早上就開始下載代碼,誰知還是沒有整完,到了晚上,也就下了40%多,然後像死了一樣不動。不忍心電腦累了一天,晚上也不能休息,就把終端強制關了。第二天,由於要上班,也只能晚上來搞代碼,誰知也是搞了一會就搞不動了,也只能強制關掉。之後再repo sync,總是在10%左右的時候,就提示fetch error,然後只能強制關掉。如此反復幾次,搞的更嚴重了,網都連不上了。後來在網上搜了好多解決方案,也嘗試重新安裝網卡驅動,不過還是沒有化險為夷。沒辦法,只能重新安裝ubuntu。

這次不敢怠慢了。剛好有天夜裡兩點多醒來了,就起來,開始取android代碼,早上8點多醒來,總算取完了,之後開始編譯,不過也不是一帆風順。

開始,是編譯的時候出現以下錯誤:

/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: 沒有該文件或目錄

解決方法:

安裝libc6-dev-i386。命令:sudo apt-get install libc6-dev-i386
當然,首先要確定系統是x86_64 GNU/Linux

使用命令:uname -a

如果得到如下的結果,說明是OK的了。

Linux mm-desktop 2.6.27-9-generic #1 SMP Thu Nov 20 22:15:32 UTC 2008 x86_64 GNU/Linux

出現如下錯誤:

cannot find -lstdc++

解決方法:

apt-get install g++-multilib

apt-get install lib32z1-dev

apt-get install lib32ncurses5-dev

接下來出現的錯誤,著實讓我費了不少勁。
錯誤內容如下:
---------------------------------------------------------------------------------------------
host C++: aidl <= out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp
frameworks/base/tools/aidl/aidl_language_l.l: In function ‘int yylex()’:
frameworks/base/tools/aidl/aidl_language_l.l:58: error: ‘IMPORT’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:59: error: ‘IMPORT’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:63: error: ‘PACKAGE’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:64: error: ‘PACKAGE’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:82: error: ‘PARCELABLE’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:82: error: ‘PARCELABLE’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:83: error: ‘INTERFACE’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:83: error: ‘INTERFACE’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:84: error: ‘IN’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:84: error: ‘IN’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:85: error: ‘OUT’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:85: error: ‘OUT’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:86: error: ‘INOUT’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:86: error: ‘INOUT’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:87: error: ‘ONEWAY’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:87: error: ‘ONEWAY’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:89: error: ‘ARRAY’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:89: error: ‘ARRAY’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:91: error: ‘IDENTIFIER’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:91: error: ‘IDENTIFIER’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:93: error: ‘GENERIC’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:93: error: ‘GENERIC’ was not declared in this scope
frameworks/base/tools/aidl/aidl_language_l.l:98: error: ‘IDENTIFIER’ was not declared in this scope
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.o] 錯誤 1
--------------------------------------------------------------------------------------------
網上搜尋解決方案,有位老兄說,改下文件build/core/definitions.mk,可以解決。

方案:
The solution - at least for me - is simply to remove the offending lines *
716:721* in *build/core/definitions.mk* (I am speaking about the version
committed on Sun, 16 Jan 2011 18:14:04 UTC<http://android.git.kernel.org/?p=platform/build.git;a=blob;f=core/def...>
)

我的代碼比較新,然後就找到了該文件 Sun, 16 Jan 2011 18:14:04 UTC時的提交,找到了對應的語句,修改之後,make,error依舊。該藥方對我無效。

繼續搜尋,有位老兄說,在apt-get instal flex之前,rm -rf out/就OK了。

方案:
user should rm -rf out/ when apt-get instal flex and software
requirements compile needed by android

按照該方案,執行了下rm -rf out/,然後再apt-get instal flex,果然藥到病除。

先總結以上。
有教訓了再繼續追加。

Copyright © Linux教程網 All Rights Reserved