这周突然心血来潮,很久没玩过android的源码了,决定下个最新的4.0回来看看,但是notebook最新装的是fedora16的系统,发现有些地方和以前旧版本的要求不一样,下面就一点一点记录下来,免得以后忘记吧,呵呵
1. JDK 6
这个需要到sun的网站下载一个安装即可: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html
下载完之后chmod再运行安装2. 最新的android源码要求make的版本为3.81, make 3.82的版本貌似有些兼容性的问题,试了下需要做些手脚才能顺利地downgrade回旧的版本
运行命令
sudo yum downgrade make --releasever=13 --nogpg
最后为了防止系统每次自动把make更新回3.82,我们在/etc/yum.conf里再添加一行来过滤掉make的自动升级
exclude=make
3. 缺失的系统工具
我的fedora16安装的时候选择的是software development的配置安装的,编译的时候出错需要安装的工具包括
sudo yum install gperf perl-Switch
4. 编译过程中的错误
a) perl错误
Can't locate Switch.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp] Error 2
make: *** Waiting for unfinished jobs....
target Generated: libwebcore <= external/webkit/Source/WebCore/platform/ColorData.gperf
Can't locate Switch.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/platform/ColorData.cpp] Error 2
target Generated: libwebcore <= external/webkit/Source/WebCore/html/parser/HTMLEntityNames.in
这个错误是由于fedora16中新的perl版本将switch的module拿掉了,需要修改webkit的源码来编译通过:
进入external/webkit的目录,打下面的patch
diff --git a/Source/WebCore/make-hash-tools.pl b/Source/WebCore/make-hash-tools.pl
index 37639eb..2968beb 100644
--- a/Source/WebCore/make-hash-tools.pl
+++ b/Source/WebCore/make-hash-tools.pl
@@ -20,7 +20,8 @@
# Boston, MA 02110-1301, USA.
use strict;
-use Switch;
+# use Switch;
+use feature qw(switch);
use File::Basename;
my $outdir = $ARGV[0];
@@ -28,9 +29,9 @@ shift;
my $option = basename($ARGV[0],".gperf");
-switch ($option) {
+given ($option) {
-case "DocTypeStrings" {
+when ("DocTypeStrings") {
my $docTypeStringsGenerated = "$outdir/DocTypeStrings.cpp";
my $docTypeStringsGperf = $ARGV[0];
@@ -40,7 +41,7 @@ case "DocTypeStrings" {
} # case "DocTypeStrings"
-case "ColorData" {
+when ("ColorData") {
my $colorDataGenerated = "$outdir/ColorData.cpp";
my $colorDataGperf = $ARGV[0];
b) mutable错误
external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
解决方法:
external/oprofile里打patch或者自己手动修改文件
diff --git a/libpp/format_output.h b/libpp/format_output.h
index b6c4592..4efdbb1 100644
--- a/libpp/format_output.h
+++ b/libpp/format_output.h
@@ -91,7 +91,8 @@ protected:
symbol_entry const & symbol;
sample_entry const & sample;
size_t pclass;
- mutable counts_t & counts;
+// mutable counts_t & counts;
+ counts_t & counts;
extra_images const & extra;
double diff;
};
c) gtest错误
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
解决:
external/gtest里打patch或者自己手动修改
diff --git a/include/gtest/internal/gtest-param-util.h b/include/gtest/internal/gtest-param-util.h
index 5559ab4..b964c45 100644
--- a/include/gtest/internal/gtest-param-util.h
+++ b/include/gtest/internal/gtest-param-util.h
@@ -37,6 +37,7 @@
#include <iterator>
#include <utility>
#include <vector>
+#include <cstddef>
#include <gtest/internal/gtest-port.h>
d) werror错误
frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]
解决:
进frameworks/compile/slang打patch或者手动修改
diff --git a/Android.mk b/Android.mk
index fce3637..aff5b7d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -19,7 +19,8 @@ ifeq ($(TARGET_BUILD_APPS),)
LOCAL_PATH := $(call my-dir)
-local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
+#local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
+local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter
ifneq ($(TARGET_BUILD_VARIANT),eng)
local_cflags_for_slang += -D__DISABLE_ASSERTS
endif
e) libx11错误
/usr/bin/ld: out/host/linux-x86/obj/EXECUTABLES/emulator_renderer_intermediates/main.o: undefined reference to symbol 'XInitThreads'
解决:
进development打patch或者手动修改
diff --git a/tools/emulator/opengl/host/renderer/Android.mk b/tools/emulator/opengl/host/renderer/Android.mk
index 55fcb80..5e4d0bb 100644
--- a/tools/emulator/opengl/host/renderer/Android.mk
+++ b/tools/emulator/opengl/host/renderer/Android.mk
@@ -5,6 +5,7 @@ $(call emugl-begin-host-executable,emulator_renderer)
$(call emugl-import,libOpenglRender)
LOCAL_SRC_FILES := main.cpp
LOCAL_CFLAGS += -O0 -g
+LOCAL_LDLIBS += -lX11
#ifeq ($(HOST_OS),windows)
#LOCAL_LDLIBS += -lws2_32