非常重要的,下载完成之后需要打几个补丁,请分别执行以下命令,按顺序打以下四个补丁:
cd build
git pull git://android.git.kernel.org/platform/build refs/changes/74/12074/3
cd system/core
git pull git://android.git.kernel.org/platform/system/core refs/changes/45/11845/3
cd external/qemu
git pull git://android.git.kernel.org/platform/external/qemu refs/changes/46/11846/3
cd system/core
git pull git://android.git.kernel.org/platform/system/core refs/changes/97/12597/1
3.下载并安装XCode和MacPorts
首先下载安装最新的XCode,下载地址:http://developer.apple.com
然后下载MacPorts,下载地址: http://www.macports.org/
修改~/.profile文件,添加:
# set the number of open files to be 1024
ulimit -S -n 1024
4.编译源码
首先修改~/.profile文件,内容类似:
# MacPorts Installer addition on 2010-05-19_at_19:14:53: adding an appropriate PATH variable for use with MacPorts.
export ANDROID_PRODUCT_OUT=/Volumes/android/Android-Source/out/target/product/generic
export ANDROID_PRODUCT_OUT_BIN=/Volumes/android/Android-Source/out/host/darwin-x86/bin
export PATH=/opt/local/bin:/opt/local/sbin:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT}:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
# MacPorts Installer addition on 2010-05-19_at_19:14:53: adding an appropriate MANPATH variable for use with MacPorts.
export MANPATH=/opt/local/share/man:$MANPATH
# Finished adapting your MANPATH environment variable for use with MacPorts.
然后打开一个新的命令行窗口,执行以下命令:
$ cd /Volumes/android/Android-Source
$ make
源码编译时间较长,大概需要4~5个小时,请耐心等待,编译完成之后,执行命令:
$ emulator
将 调出模拟器,说明编译成功!
1. 打最后补丁时出错,错误如下:
“Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use ‘git add/rm ‘
as appropriate to mark resolution, or use ‘git commit -a’.”
改用命令:
“git clone git://android.git.kernel.org/platform/system/core refs/changes/97/12597/1″
出错原因:
./external/elfutils/config-compat-darwin.h:42: error: static declaration of ‘strnlen’ follows non-static declaration
/usr/include/string.h:143: error: previous declaration of ‘strnlen’ was here
make: *** [out/host/darwin-x86/obj/STATIC_LIBRARIES/libelf_intermediates/lib/xmalloc.o] Error 1
static inline size_t strnlen (const char *__string, size_t __maxlen)
{
int len = 0;
while (__maxlen-- && *__string++)
len++;
return len;
}
with:
#if 0
static inline size_t strnlen (const char *__string, size_t __maxlen)
{
int len = 0;
while (__maxlen-- && *__string++)
len++;
return len;
}
#endif
Well, at the end of the process I just edited the Android.mk makefile into external/skia adding a new entry for BUILD_STATIC_LIBRARY and the next command was simply:
mmm external/skia
which produced the required libskia.a file to be linked in my project.
第二个问题:
warning: ignoring file out/host/darwin-x86/obj/STATIC_LIBRARIES/
libSDL_intermediates/libSDL.a, file was built for archive which is not
the architecture being linked (i386)
Undefined symbols for architecture i386:
Do this by commenting out all lines in
external/qemu/Android.mk
The toolchain problem stems from the fact that Android actually supports the mac toolchain from Snow Leopard and onwards. So put homebrew path LAST in $PATH, so that it uses the Mac toolchain first.
When building DevNull/Oxygen ROM you in addition to the steps above also need to make a symlink in /usr/local/bin from sed to gsed, since they explicitly call gsed at one point. Also you have to disable WITH_DEXPREOPT like so:
make -j8 [devnull] WITH_DEXPREOPT=false