Build Android 5.1.1 on OSX 10.10 Yosemite With Xcode7

参考:https://medium.com/@raminmahmoodi/build-android-5-0-lollipop-on-osx-10-10-yosemite-441bd00ee77a

           http://www.bubuko.com/infodetail-471094.html

首先,本人以前没有使用过MacBook做过开发,对于MacBook不慎了解。

一、下载Android源码:

现在访问Android网站需要,因此建议使用清华大学的一个镜像来下载Android源码,具体可以百度一下。

二、编译Android源码:

2.1 创建一个镜像。

    因为源码只能在大小写敏感的磁盘上编译(红色字体标示可以自行配置的参数,下同

    hdiutil create -type SPARSE -fs ‘Case-sensitive Journaled HFS+’ -size 100g~/android.dmg.sparsefile

    这里分了100G硬盘

2.2 加载分区

    hdiutil attach ~/android.dmg.sparsefile -mountpoint~/Android

2.3 下载相应的工具

    java

    下载jdk7: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

    jdk安装参考:http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html

    make

2.4 修改文件描述符限制

    在~/.bash_profile中添加以下内容:

     # set the number of open files to be 1024 

  ulimit -S -n 1024

2.5 安装MacPort

If on the other hand you decide to install MacPorts from source, there are still a couple of things you will need to do after downloading the tarball before you can start installing ports, namely compiling and installing MacPorts itself:

1 “cd” into the directory where you downloaded the package and run “tar xjvf MacPorts-2.3.3.tar.bz2” or “tar xzvf MacPorts-2.3.3.tar.gz”, depending on whether you downloaded the bz2 tarball or the gz one, respectively.

2 Build and install the recently unpacked sources:

cd MacPorts-2.3.3

./configure && make && sudo make install

3 Optionally:

cd ../

rm -rf MacPorts-2.3.3*


将/opt/local/bin和/opt/local/sbin添加到$PATH搜索路径中

编辑/etc/profile文件 $ sudo vim /etc/profile (特许编辑,强制保存退出 wq!)文件

export PATH=/opt/local/bin:$PATH

export PATH=/opt/local/sbin:$PATH


POSIXLY_CORRECT=1 sudo port install gmake libsdl git gnupg

如果出现Error: Port gmake not found,请用以下命令:

sudo port -d sync.


三、编译错误

3.1  xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance


解决办法:

1)   Install Xcode (get it fromhttp://developer.apple.com) if you don’t have it yet,

2)  Point xcode-select to the Xcode Developer directory using the following command:sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Note: Make sure your Xcode app directory is the same as in the address above; most notably, it’ll be probably /Applications/Xcode-Beta.app/Contents/Developer if you installed beta XCode release instead.


3.2、Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

解决办法:

根据提示 打开 Xcode 点击同意,就安装提示了,安装之后再看看 Ok。


3.3、build/core/combo/mac_version.mk:38: *****************************************************

build/core/combo/mac_version.mk:39: * Can not find SDK 10.6 at /Developer/SDKs/MacOSX10.6.sdk

build/core/combo/mac_version.mk:40: *****************************************************

build/core/combo/mac_version.mk:41: *** Stop..  Stop.

解决办法:

这是因为macos 10.10的Xcode已经更新到7.x了,同样sdk也更新到10.11。可以前往查看你得sdk版本,具体路径在:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

如果你跟我一样的系统版本,你会发现该目录下只有MacOSX10.11.sdk一个版本。没有10.6了,所以解决方案:

1) 装一个低版本的Xcode;

2) 改一下配置文件,修改方法为:

//前提是你在WORKING_DIRECTORY目录下

$ vi ./build//core/combo/mac_version.mk

//找到mac_sdk_versions_supported

mac_sdk_versions_supported :=  10.6 10.7 10.8 10.9

//将上面这行换成

mac_sdk_versions_supported :=  10.11 10.10 10.9

//就是换一下支持的sdk版本号。


3.4 system/core/include/log/log.h:35:20: error: stdarg.h: No such file or directory

解决办法:

这其实也是Xcode版本惹的祸!还是在build/core/combo/HOST_darwin-x86.mk里面

ifeq ($(mac_sdk_version),10.8 10.9)

# Mac SDK 10.8 no longer has stdarg.h, etc

host_toolchain_header := $(HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include

HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header)

endif

else


这里只判断了10.8 10.9。在10.8里面就已经没有stdarg.h了,那么在我们的10.9、10.10、10.11里面肯定也没有了。但是却没有走进这个判断。所以更改很简单,增加10.10 10.11的判断


3.5  host C++: validatekeymaps <= frameworks/base/tools/validatekeymaps/Main.cpp

:0: error: Unknown value ‘10.11’ of -mmacosx-version-min

解决办法:

需要下载老版本的Xcode来编译,下载地址:

Xcode 7

7.1 beta: https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_7.1_beta/Xcode_7.1_beta.dmg

7.0 : https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_7/Xcode_7.dmg

Xcode 6

6.4: http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg

6.3.2: http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.3.2/Xcode_6.3.2.dmg

6.2: http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.2/Xcode_6.2.dmg

6.1.1: https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_6.1.1/xcode_6.1.1.dmg

6.0.1: https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_6.0.1/xcode_6.0.1.dmg

Xcode 5

5.1.1: https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_5.1.1/xcode_5.1.1.dmg

5.0.2: https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_5.0.2/xcode_5.0.2.dmg

Xcode 4

4.6.3: https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.6.3/xcode4630916281a.dmg

4.5.2: https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.5.2/xcode4520418508a.dmg

4.4.1: https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.4.1/xcode_4.4.1_6938145.dmg

4.3.2: https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.3.2/xcode_432_lion.dmg

4.2: http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.2_for_lion_21264/installxcode_42_lion.dmg

4.1: http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.1_for_lion_21263/installxcode_41_lion.dmg

4.0.2: http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.0.2_and_ios_sdk_4.3/xcode_4.0.2_and_ios_sdk_4.3.dmg


3.6 

libnativehelper/JNIHelp.cpp:28:10: fatal error: 'string' file not found

#include

         ^

1 error generated.

make: *** [out/host/darwin-x86/obj32/SHARED_LIBRARIES/libnativehelper_intermediates/JNIHelp.o] Error 1


解决办法:

正在解决,mark一下

你可能感兴趣的:(Build Android 5.1.1 on OSX 10.10 Yosemite With Xcode7)