Ubuntu 11.04 下载和编译Android代码

最近想学习学习Android,就在自己到pc上装了Ubuntu 11.04,然后按照上的说明,进行操作。

不过,过程中也遇到了不少问题,在此做个总结。

第一次,是在进行到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<?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,果然药到病除。

先总结以上。
有教训了再继续追加。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/23703.html