[转发请注明出处,谢谢]

本文的编译环境指的是Android KernelFramework的编译,不是Application的开发环境

有详细说明的只给出链接和要点提示。


大的步骤就是Androidsource网站的原文

“Initializing a Build Environment”Setting up a Mac OS X build environment部分。


要点提示:

1. 创建case-sensitive disk image.的问题

原文提到要在~/.bash_profile文件添加mountAndroid命令。好多人找不到此文件。

其实,默认Mac OS X是没有这个文件的。可以参考下文解决

MAC上找不到.bash_profile该怎么办?” 链接:http://blog.csdn.net/edai9508/article/details/6006269

也就是要自己产生此文件,并且编辑加入内容,编辑好保存后要执行

source .bash_profile

来更新配置。


2.Xcode的问题

Android官方推荐装Xcode3.1.4版本但是先在都4.x了,其实主要是要MacOS SDK 10.5.

请参考链接:

1解决AndroidMAC OSX上编译缺少10.5SDK问题

链接:http://blog.csdn.net/dragon1225/article/details/7061076

[注释:链接文章提到编译时strnlen的错误问题,这个将下文列举]


2)10.5的SDK包可以通过这里下载

http://blog.csdn.net/guoguoljg/article/details/7300940


3.通过Macport装相关的包的过程中遇到的问题

1Python27安装错误,解决方案:自己重新找源安装即可;

2xz错误(好像和Python有关系):自己手动装xz sudo port install xz


4.编译Android遇到的问题

1)问题 error: elf.h: No such file or directory

原因:Mac缺少elf.h文件

解决方法:参考这里http://blog.csdn.net/quaful/article/details/6053708

思想:从网上下个elf头文件,放到scripts/mod/文件夹里,要修改两个文件mk_elfconfig.cmodpost.h

#include 改为#include "elf.h"


2)问题error: static declaration of ‘strnlen’ follows non-static declaration

/usr/include/string.h:143: error: previous declaration of ‘strnlen’ was here

原因:通过解决方案发现这个strnlen时多余的

解决:方案一,替换这个函数, 参考http://dyf128.iteye.com/blog/1258943

方案二,函数外围加宏或者注释掉,参考

我采用方案二,参考

#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 static inline size_t strnlen (const char *__string, size_t __maxlen){int len = 0;while (__maxlen-- && *__string++)len++;return len;}#endif



无论哪个方案都会引来下面的新问题。


(3)问题 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


原因:不明

解决:注释掉Android.mk的所有内容

参考:

# the following test is made to detect that we were called# through the 'm' or 'mm' build commands. if not, we use the# standard QEMU Makefile####################Comment by Damon on June 28, 2012############################ifeq ($(DEFAULT_GOAL),droid)#    LOCAL_PATH:= $(call my-dir)#    include $(LOCAL_PATH)/Makefile.android#else#    include Makefile.qemu#endif##############################################################


相关参考

i) http://dyf128.iteye.com/blog/1258943

ii) http://groups.google.com/group/android-building/browse_thread/thread/bd566c8b513a4946

iii) http://www.linuxidc.com/Linux/2012-06/61754.htm



更多相关文章

  1. Android:inflate.inflate()方法
  2. Android模拟器SD卡的使用
  3. android 在APP内打开在线的office文件
  4. android自定义控件打包成jar文件
  5. Android(安卓)Studio报错:Android(安卓)studio 3.0 com.android.b
  6. windows系统上使用Android(安卓)NDK r5
  7. Android(安卓)Studio--活动创建&简单布局
  8. Android(安卓)的 dex2jar 和 jd-gui 反编译 apk 源代码
  9. Android(安卓)Studio如何轻松整理字符串到string.xml中

随机推荐

  1. AndroidStudio学习(二)-模拟小相册
  2. android中的wife
  3. 设置Textview最大长度,超出显示省略号
  4. Android(安卓)studio报错Could not GET
  5. RelativeLayout相关属性
  6. 【Android】编译CM10.1遇到的错误解决方
  7. android SDK dl fetched
  8. 2.4.9 列表视图
  9. android sdk manager 下载更新失败
  10. ADT下载地址整理