OS X 10.10.5编译Android5.1.1源码
--------------------------------------------------写在前面--------------------------------------------------
由于在编译过程中遇到了很多奇奇怪怪的、难解的问题~~~
到后面,实际上还是在macmini中安装了Ubuntu系统,最后在Ubuntu系统下完成的Android源码编译。
以下就是在OS X系统中进行编译时遇到的一些问题和解决办法,聊作记录。
--------------------------------------------------写在前面--------------------------------------------------
参考:Build Android 5.1.1 on OSX 10.10 Yosemite With Xcode7
一、环境配置
电脑:Mac Mini (OS X 10.10.5)
内存:2 GB 1333 MHz DDR3
XCode:XCode 7.1 beta
二、错误
(1)
select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
解决办法:
sudo xcode-select --switch /Applications/Xcode-beta.app
(2)
build/core/combo/mac_version.mk:38: ***************************************************** build/core/combo/mac_version.mk:39: * Can not find SDK 10.10 at /Developer/SDKs/MacOSX10.10.sdk build/core/combo/mac_version.mk:40: *****************************************************
解决办法:在build/core/combo/mac_version.mk文件中将mac_supported_versions 增加10.11
mac_sdk_versions_supported := 10.6 10.7 10.8 10.9 10.10 10.11
(3)
build/core/main.mk:116: ************************************************************ build/core/main.mk:117: You are building on a case-insensitive filesystem. build/core/main.mk:118: Please move your source tree to a case-sensitive filesystem. build/core/main.mk:119: ************************************************************ build/core/main.mk:120: *** Case-insensitive filesystems not supported. Stop.
Android源代码必须在大小写敏感的文件系统下编译,而Mac OS默认不是大小写敏感的,因此需要创建一个大小写敏感的磁盘分区。
解决办法:
使用磁盘工具分出一个格式为(MAC OS 日志式、区分大小写)的分区。
出现“分区无法验证”的错误提示“无法分区”时,重启电脑,在电脑一启动时按下COMMAND+S不动,进入单用户模式,输入fsck -f命令,修复磁盘后,输入reboot重启电脑,再次用磁盘工具进行分区即可。
(4)
host C++: validatekeymaps <= frameworks/base/tools/validatekeymaps/Main.cpp <built-in>:0: error: Unknown value ‘10.11’ of -mmacosx-version-min In file included from system/core/include/cutils/log.h:1, from system/core/include/utils/KeyedVector.h:24, from frameworks/native/include/input/Input.h:26, from frameworks/native/include/input/KeyCharacterMap.h:26, from frameworks/base/tools/validatekeymaps/Main.cpp:17: system/core/include/log/log.h:35:20: error: stdarg.h: No such file or directory make: *** [out/host/darwin-x86/obj32/EXECUTABLES/validatekeymaps_intermediates/Main.o] Error 1
解决办法:
在build/core/combo/HOST_darwin-x86.mk里面,增加10.10 10.11的判断:
ifneq ($(filter 10.8 10.9 10.10 10.11, $(mac_sdk_version)),) # Mac SDK 10.8+ no longer has stdarg.h, etc host_toolchain_header := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include $(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header) endif
(5)
<built-in>:0: error: Unknown value ‘10.11’ of -mmacosx-version-min make: *** [out/host/darwin-x86/obj32/EXECUTABLES/validatekeymaps_intermediates/Main.o] Error 1
解决办法:
下载低版本的XCode(XCode 6.1.1),获取OS X 10.9的SDK.