今天又重新编译了一下android 源码,中间出现的问题简单罗列一下。
1、系统环境:
VM虚拟机10.0.2 + linux 14.04_64bit 这个就不展开
2、系统环境
大部分参考 官网: http://source.android.com/source/initializing.html
(1)JDK
以下是摘自官网:
Installing the JDK
The master branch of Android in the Android Open Source Project (AOSP) requires Java 7. On Ubuntu, useOpenJDK.
Java 7: For the latest version of Android
$ sudo apt-getupdate $ sudo apt-getinstall openjdk-7-jdk
Optionally, update the default Java version by running:
$ sudo update-alternatives--config java $ sudo update-alternatives--config javac
To develop older versions of Android, download and install the corresponding version of the
Java JDK
:
Java 6: for Gingerbread through KitKat
Java 5: for Cupcake through Froyo
但我习惯使用自己的jdk,而且我编译的是 android2.3.1 的源码 使用的jdk1.6
(2) 安装编译需要的包
Installing required packages (Ubuntu 12.04)
You will need a 64-bit version of Ubuntu. Ubuntu 12.04 is recommended. Building using an older version of Ubuntu is not supported on master or recent releases.
$ sudo apt-getinstall git gnupg flex bison gperf build-essential\zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev\libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386\libgl1-mesa-dev g++-multilib mingw32 tofrodos\python-markdown libxml2-utils xsltproc zlib1g-dev:i386 $ sudo ln-s/usr/lib/i386-linux-gnu/mesa/libGL.so.1/usr/lib/i386-linux-gnu/libGL.so
(3)SDK ,这个没有必要,但是习惯把它安装了,以下是地址
3、源码下载
这个最坑爹了,基本上都下载不了,使用的 国内 android爱好者上传到网盘的包
android 2.3.1 网盘
这个需要自己找了,360云盘的好多资源都被屏蔽了
4、编译
$source build/envsetup.sh
$lunch 选择编译厂商版本。
进入源码目录
$cd android2.3.1/
执行make -j4命令 ,使用4个线程 ,数字是根据你cpu的内核数 ,如果是双核就是j2 ,我的是4核
$make -j4
5、问题处理
waring的可以不管,只处理error的错误
Ubuntu14.04 编译 android2.3.1的错误
(1)/usr/include/zlib.h:34:19: fatal error: zconf.h: No such file or directory
#include "zconf.h"
^
compilation terminated.
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1
解决
$sudo apt-get install zlib1g-dev
(2)
frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<:string8 android::sp> >’ are not found by unqualified lookup
frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1
在
frameworks/base/tools/aapt/Android.mk
在第31行增加:
LOCAL_CFLAGS += -Wno-format-y2k
-fpermissive
未解决!!
vi frameworks/base/libs/utils/Android.mk Add '-fpermissive' to line 64: LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
(3)
Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: external/webkit/WebCore/bindings/scripts /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/WebCore/dom/make_names.pl line 38.
BEGIN failed--compilation aborted at external/webkit/WebCore/dom/make_names.pl line 38.
Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: external/webkit/WebCore/bindings/scripts /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/WebCore/dom/make_names.pl line 38.
BEGIN failed--compilation aborted at external/webkit/WebCore/dom/make_names.pl line 38.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLNames.h] Error 2
make: *** Waiting for unfinished jobs....
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLElementFactory.h] Error 2
Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: external/webkit/WebCore/bindings/scripts /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/WebCore/dom/make_names.pl line 38.
BEGIN failed--compilation aborted at external/webkit/WebCore/dom/make_names.pl line 38.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/JSHTMLElementWrapperFactory.h] Error 2