不得不说在Mac下开发Android程序很蛋疼
——那么就更蛋疼一点吧,少年!来编译Android源码⋯⋯ 在*nix甚至win下这都是非常简单的事情,但目前手边上只有iMac能用,只好移到Mac OS X来干了。
其实吧,这种事在哪里做都一样,只是前戏的步骤略微有点不同罢了⋯⋯(呃,又糟糕了么?) 所以一步步地做下来,顺便就又记了个流水账:
-
建立大小写敏感硬盘镜像
-
安装一堆库和包
-
下载Android源码
-
终于开始编译了
-
要不要运行个模拟器试试?
首先,Mac OS X的版本必须比Tiger新 (i.e., 版本号在10.4或以上),而且必须是Intel处理器,PowerPC不行。
然后,由于Mac OS X使用的文件系统不是默认大小写敏感的,就需要创建一个大小写敏感的硬盘镜像。步骤如下:
Disk Utility –> New Image,随便取个名字,这里用AndroidDisk,30GB足够了,然后注意选成Mac OS Extended (Case-sensitive, Journaled), –> Create
生成的硬盘镜像文件名就是AndroidDisk.dmg了。似乎创建完以后OS会自动把这个镜像加载上去,但如果不喜欢这种方式,还是起个名字吧,用:
$ hdiutil attach /path-to-image/AndroidDisk.dmg -mountpoint /Volumes/AndroidDisk
Google的官网上推荐把这行加到~/.bash_profile里,这样以后每次用mountAndroid命令就行了。
function mountAndroid { hdiutil attach /Users/elisa/Develop/AndroidDisk.dmg -mountpoint /Volumes/AndroidDisk; }
2.1. 去Apple developer下载Xcode (要有Apple ID并注册成Developer)并安装。
* 如果你用的是Mac OS X 10.6+ (Snow Leopard)的话,可以安装XCode最新版本。
* 如果你用的是Mac OS X 10.5(Leopard)的话,可以在这样下载XCode 3.1.4:
打开Apple Developer Connection网站: http://connect.apple.com/ 以ADC会员登录 点右侧的Download 再点右侧下边一点的Developer Tools
2.2. 从macports.org.安装MacPorts
安装MacPorts之前需要确认环境变量PATH中,/opt/local/bin出现在/usr/bin之前,可以运行一下这行来确认:
$ echo $PATH
否则,就运行一下:
$ export PATH=/opt/local/bin:$PATH
并把上面那行加在~/.bash_profile里。
2.3. 从MacPorts安装make, git, and GPG packages:
$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
无聊顺手copy过来记录⋯⋯如果不手贱的话最好别点下面的那个+expand sources了!(其实这时你可以去小睡一觉⋯⋯)
$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg Password: Warning: The installed version of Xcode (3.0) is known to cause problems. Version 3.1.4 or later is recommended on Mac OS X 10.5. ---> Computing dependencies for gmake ---> Dependencies to be installed: gettext expat libiconv gperf ncurses ncursesw ---> Fetching expat ---> Attempting to fetch expat-2.0.1.tar.gz from http://downloads.sourceforge.net/expat ---> Verifying checksum(s) for expat ---> Extracting expat ---> Configuring expat ---> Building expat ---> Staging expat into destroot ---> Installing expat @2.0.1_1 ---> Activating expat @2.0.1_1 ---> Cleaning expat ---> Fetching gperf ---> Attempting to fetch gperf-3.0.4.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/gperf ---> Verifying checksum(s) for gperf ---> Extracting gperf ---> Configuring gperf ---> Building gperf ---> Staging gperf into destroot ---> Installing gperf @3.0.4_0 ---> Activating gperf @3.0.4_0 ---> Cleaning gperf ---> Fetching libiconv ---> Attempting to fetch libiconv-1.13.1.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/libiconv ---> Verifying checksum(s) for libiconv ---> Extracting libiconv ---> Applying patches to libiconv ---> Configuring libiconv ---> Building libiconv ---> Staging libiconv into destroot ---> Installing libiconv @1.13.1_0 ---> Activating libiconv @1.13.1_0 ---> Cleaning libiconv ---> Fetching ncursesw ---> Verifying checksum(s) for ncursesw ---> Extracting ncursesw ---> Configuring ncursesw ---> Building ncursesw ---> Staging ncursesw into destroot ---> Installing ncursesw @5.8_0 ---> Activating ncursesw @5.8_0 ---> Cleaning ncursesw ---> Fetching ncurses ---> Attempting to fetch ncurses-5.9.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/ncurses ---> Verifying checksum(s) for ncurses ---> Extracting ncurses ---> Applying patches to ncurses ---> Configuring ncurses ---> Building ncurses ---> Staging ncurses into destroot ---> Installing ncurses @5.9_0 ---> Activating ncurses @5.9_0 ---> Cleaning ncurses ---> Fetching gettext ---> Attempting to fetch gettext-0.18.1.1.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/gettext ---> Verifying checksum(s) for gettext ---> Extracting gettext ---> Applying patches to gettext ---> Configuring gettext ---> Building gettext ---> Staging gettext into destroot ---> Installing gettext @0.18.1.1_2 ---> Activating gettext @0.18.1.1_2 ---> Cleaning gettext ---> Fetching gmake ---> Attempting to fetch make-3.82.tar.bz2 from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/make ---> Verifying checksum(s) for gmake ---> Extracting gmake ---> Configuring gmake ---> Building gmake ---> Staging gmake into destroot ---> Installing gmake @3.82_0 ---> Activating gmake @3.82_0 ---> Cleaning gmake Warning: The installed version of Xcode (3.0) is known to cause problems. Version 3.1.4 or later is recommended on Mac OS X 10.5. ---> Computing dependencies for libsdl ---> Dependencies to be installed: xorg-libXext pkgconfig xorg-libX11 xorg-bigreqsproto xorg-inputproto xorg-kbproto xorg-libXau xorg-xproto xorg-libXdmcp xorg-libxcb python27 bzip2 db46 gdbm openssl zlib readline sqlite3 xorg-libpthread-stubs xorg-xcb-proto libxml2 xorg-util-macros xorg-xcmiscproto xorg-xextproto xorg-xf86bigfontproto xorg-xtrans xorg-libXrandr xorg-randrproto xrender xorg-renderproto ---> Fetching pkgconfig ---> Attempting to fetch pkg-config-0.25.tar.gz from http://pkg-config.freedesktop.org/releases/ ---> Verifying checksum(s) for pkgconfig ---> Extracting pkgconfig ---> Applying patches to pkgconfig ---> Configuring pkgconfig ---> Building pkgconfig ---> Staging pkgconfig into destroot ---> Installing pkgconfig @0.25_2 ---> Activating pkgconfig @0.25_2 ---> Cleaning pkgconfig ---> Fetching xorg-bigreqsproto ---> Attempting to fetch bigreqsproto-1.1.1.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto/ ---> Verifying checksum(s) for xorg-bigreqsproto ---> Extracting xorg-bigreqsproto ---> Configuring xorg-bigreqsproto ---> Building xorg-bigreqsproto ---> Staging xorg-bigreqsproto into destroot ---> Installing xorg-bigreqsproto @1.1.1_0 ---> Activating xorg-bigreqsproto @1.1.1_0 ---> Cleaning xorg-bigreqsproto ---> Fetching xorg-inputproto ---> Attempting to fetch inputproto-2.0.1.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto/ ---> Verifying checksum(s) for xorg-inputproto ---> Extracting xorg-inputproto ---> Configuring xorg-inputproto ---> Building xorg-inputproto ---> Staging xorg-inputproto into destroot ---> Installing xorg-inputproto @2.0.1_0 ---> Activating xorg-inputproto @2.0.1_0 ---> Cleaning xorg-inputproto ---> Fetching xorg-kbproto ---> Attempting to fetch kbproto-1.0.5.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto/ ---> Verifying checksum(s) for xorg-kbproto ---> Extracting xorg-kbproto ---> Configuring xorg-kbproto ---> Building xorg-kbproto ---> Staging xorg-kbproto into destroot ---> Installing xorg-kbproto @1.0.5_0 ---> Activating xorg-kbproto @1.0.5_0 ---> Cleaning xorg-kbproto ---> Fetching xorg-xproto ---> Attempting to fetch xproto-7.0.21.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto ---> Verifying checksum(s) for xorg-xproto ---> Extracting xorg-xproto ---> Configuring xorg-xproto ---> Building xorg-xproto ---> Staging xorg-xproto into destroot ---> Installing xorg-xproto @7.0.21_0 ---> Activating xorg-xproto @7.0.21_0 ---> Cleaning xorg-xproto ---> Fetching xorg-libXau ---> Attempting to fetch libXau-1.0.6.tar.bz2 from http://xorg.freedesktop.org/archive/individual/lib/ ---> Verifying checksum(s) for xorg-libXau ---> Extracting xorg-libXau ---> Configuring xorg-libXau ---> Building xorg-libXau ---> Staging xorg-libXau into destroot ---> Installing xorg-libXau @1.0.6_0 ---> Activating xorg-libXau @1.0.6_0 ---> Cleaning xorg-libXau ---> Fetching xorg-libXdmcp ---> Attempting to fetch libXdmcp-1.1.0.tar.bz2 from http://xorg.freedesktop.org/archive/individual/lib ---> Verifying checksum(s) for xorg-libXdmcp ---> Extracting xorg-libXdmcp ---> Configuring xorg-libXdmcp ---> Building xorg-libXdmcp ---> Staging xorg-libXdmcp into destroot ---> Installing xorg-libXdmcp @1.1.0_0 ---> Activating xorg-libXdmcp @1.1.0_0 ---> Cleaning xorg-libXdmcp ---> Fetching bzip2 ---> Attempting to fetch bzip2-1.0.6.tar.gz from http://www.bzip.org/1.0.6 ---> Verifying checksum(s) for bzip2 ---> Extracting bzip2 ---> Applying patches to bzip2 ---> Configuring bzip2 ---> Building bzip2 ---> Staging bzip2 into destroot ---> Installing bzip2 @1.0.6_0 ---> Activating bzip2 @1.0.6_0 ---> Cleaning bzip2 ---> Fetching db46 ---> Attempting to fetch patch.4.6.21.1 from http://download.oracle.com/berkeley-db/patches/db/4.6.21/ ---> Attempting to fetch patch.4.6.21.2 from http://download.oracle.com/berkeley-db/patches/db/4.6.21/ ---> Attempting to fetch patch.4.6.21.3 from http://download.oracle.com/berkeley-db/patches/db/4.6.21/ ---> Attempting to fetch patch.4.6.21.4 from http://download.oracle.com/berkeley-db/patches/db/4.6.21/ ---> Attempting to fetch db-4.6.21.tar.gz from http://download-west.oracle.com/berkeley-db/ ---> Verifying checksum(s) for db46 ---> Extracting db46 ---> Applying patches to db46 ---> Configuring db46 ---> Building db46 ---> Staging db46 into destroot ---> Installing db46 @4.6.21_6 ---> Activating db46 @4.6.21_6 ---> Cleaning db46 ---> Fetching gdbm ---> Attempting to fetch gdbm-1.8.3.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/gdbm ---> Verifying checksum(s) for gdbm ---> Extracting gdbm ---> Configuring gdbm ---> Building gdbm ---> Staging gdbm into destroot ---> Installing gdbm @1.8.3_3 ---> Activating gdbm @1.8.3_3 ---> Cleaning gdbm ---> Fetching zlib ---> Attempting to fetch zlib-1.2.5.tar.bz2 from http://www.zlib.net/ ---> Verifying checksum(s) for zlib ---> Extracting zlib Error: On Mac OS X 10.5, zlib 1.2.5 requires Xcode 3.1 or later but you have Xcode 3.0. Error: Target org.macports.extract returned: incompatible Xcode version Error: Failed to install zlib Log for zlib is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_archivers_zlib/main.log Error: The following dependencies were not installed: xorg-libXext xorg-libX11 xorg-libxcb python27 openssl zlib readline sqlite3 xorg-libpthread-stubs xorg-xcb-proto libxml2 xorg-util-macros xorg-xcmiscproto xorg-xextproto xorg-xf86bigfontproto xorg-xtrans xorg-libXrandr xorg-randrproto xrender xorg-renderproto Error: Status 1 encountered during processing. To report a bug, see $ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg Password: ---> Computing dependencies for gmake ---> Cleaning gmake ---> Computing dependencies for libsdl ---> Dependencies to be installed: xorg-libXext xorg-libX11 xorg-libxcb python27 openssl zlib readline sqlite3 xorg-libpthread-stubs xorg-xcb-proto libxml2 xorg-util-macros xorg-xcmiscproto xorg-xextproto xorg-xf86bigfontproto xorg-xtrans xorg-libXrandr xorg-randrproto xrender xorg-renderproto ---> Extracting zlib ---> Applying patches to zlib ---> Configuring zlib ---> Building zlib ---> Staging zlib into destroot ---> Installing zlib @1.2.5_0 ---> Activating zlib @1.2.5_0 ---> Cleaning zlib ---> Fetching openssl ---> Attempting to fetch openssl-1.0.0d.tar.gz from http://www.openssl.org/source/ ---> Verifying checksum(s) for openssl ---> Extracting openssl ---> Applying patches to openssl ---> Configuring openssl ---> Building openssl ---> Staging openssl into destroot ---> Installing openssl @1.0.0d_0 ---> Activating openssl @1.0.0d_0 ---> Cleaning openssl ---> Fetching readline ---> Attempting to fetch readline-6.2.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/readline ---> Verifying checksum(s) for readline ---> Extracting readline ---> Applying patches to readline ---> Configuring readline ---> Building readline ---> Staging readline into destroot ---> Installing readline @6.2.000_0 ---> Activating readline @6.2.000_0 ---> Cleaning readline ---> Fetching sqlite3 ---> Attempting to fetch sqlite-autoconf-3070600.tar.gz from http://www.sqlite.org/ ---> Verifying checksum(s) for sqlite3 ---> Extracting sqlite3 ---> Applying patches to sqlite3 ---> Configuring sqlite3 ---> Building sqlite3 ---> Staging readline into destroot ---> Installing readline @6.2.000_0 ---> Activating readline @6.2.000_0 ---> Cleaning readline ---> Fetching sqlite3 ---> Attempting to fetch sqlite-autoconf-3070600.tar.gz from http://www.sqlite.org/ ---> Verifying checksum(s) for sqlite3 ---> Extracting sqlite3 ---> Applying patches to sqlite3 ---> Configuring sqlite3 ---> Building sqlite3 ---> Staging sqlite3 into destroot ---> Installing sqlite3 @3.7.6_0 ---> Activating sqlite3 @3.7.6_0 ---> Cleaning sqlite3 ---> Fetching python27 ---> Attempting to fetch Python-2.7.1.tar.bz2 from http://www.python.org//ftp/python/2.7.1/ ---> Verifying checksum(s) for python27 ---> Extracting python27 ---> Applying patches to python27 ---> Configuring python27 ---> Building python27 ---> Staging python27 into destroot ---> Installing python27 @2.7.1_1 ---> Activating python27 @2.7.1_1 To fully complete your installation and make python 2.7 the default, please run: sudo port install python_select sudo python_select python27 ---> Cleaning python27 ---> Fetching xorg-libpthread-stubs ---> Attempting to fetch libpthread-stubs-0.3.tar.bz2 from http://xcb.freedesktop.org/dist/ ---> Verifying checksum(s) for xorg-libpthread-stubs ---> Extracting xorg-libpthread-stubs ---> Configuring xorg-libpthread-stubs --> ---> Building xorg-libpthread-stubs ---> Staging xorg-libpthread-stubs into destroot ---> Installing xorg-libpthread-stubs @0.3_0 ---> Activating xorg-libpthread-stubs @0.3_0 ---> Cleaning xorg-libpthread-stubs ---> Fetching libxml2 ---> Attempting to fetch libxml2-2.7.8.tar.gz from ftp://fr.rpmfind.net/pub/libxml/ ---> Verifying checksum(s) for libxml2 ---> Extracting libxml2 ---> Configuring libxml2 ---> Building libxml2 ---> Staging libxml2 into destroot ---> Installing libxml2 @2.7.8_0 ---> Activating libxml2 @2.7.8_0 ---> Cleaning libxml2 ---> Fetching xorg-xcb-proto ---> Attempting to fetch xcb-proto-1.6.tar.bz2 from http://xcb.freedesktop.org/dist/ ---> Verifying checksum(s) for xorg-xcb-proto ---> Extracting xorg-xcb-proto ---> Configuring xorg-xcb-proto ---> Building xorg-xcb-proto ---> Staging xorg-xcb-proto into destroot ---> Installing xorg-xcb-proto @1.6_0+python27 ---> Activating xorg-xcb-proto @1.6_0+python27 ---> Cleaning xorg-xcb-proto ---> Fetching xorg-libxcb ---> Attempting to fetch libxcb-1.7.tar.bz2 from http://xcb.freedesktop.org//dist/ ---> Verifying checksum(s) for xorg-libxcb ---> Extracting xorg-libxcb ---> Configuring xorg-libxcb ---> Building xorg-libxcb ---> Staging xorg-libxcb into destroot ---> Installing xorg-libxcb @1.7_0+python27 ---> Activating xorg-libxcb @1.7_0+python27 ---> Cleaning xorg-libxcb ---> Fetching xorg-util-macros ---> Attempting to fetch util-macros-1.13.0.tar.bz2 from http://xorg.freedesktop.org/archive/individual/util/ ---> Verifying checksum(s) for xorg-util-macros ---> Extracting xorg-util-macros ---> Configuring xorg-util-macros ---> Building xorg-util-macros ---> Staging xorg-util-macros into destroot ---> Installing xorg-util-macros @1.13.0_0 ---> Activating xorg-util-macros @1.13.0_0 ---> Cleaning xorg-util-macros ---> Fetching xorg-xcmiscproto ---> Attempting to fetch xcmiscproto-1.2.1.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto/ ---> Verifying checksum(s) for xorg-xcmiscproto ---> Extracting xorg-xcmiscproto ---> Configuring xorg-xcmiscproto ---> Building xorg-xcmiscproto ---> Staging xorg-xcmiscproto into destroot ---> Installing xorg-xcmiscproto @1.2.1_0 ---> Activating xorg-xcmiscproto @1.2.1_0 ---> Cleaning xorg-xcmiscproto ---> Fetching xorg-xextproto ---> Attempting to fetch xextproto-7.2.0.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto ---> Verifying checksum(s) for xorg-xextproto ---> Extracting xorg-xextproto ---> Configuring xorg-xextproto ---> Building xorg-xextproto ---> Staging xorg-xextproto into destroot ---> Installing xorg-xextproto @7.2.0_0 ---> Activating xorg-xextproto @7.2.0_0 ---> Cleaning xorg-xextproto ---> Fetching xorg-xf86bigfontproto ---> Attempting to fetch xf86bigfontproto-1.2.0.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto/ ---> Verifying checksum(s) for xorg-xf86bigfontproto ---> Extracting xorg-xf86bigfontproto ---> Configuring xorg-xf86bigfontproto ---> Building xorg-xf86bigfontproto ---> Staging xorg-xf86bigfontproto into destroot ---> Installing xorg-xf86bigfontproto @1.2.0_0 ---> Activating xorg-xf86bigfontproto @1.2.0_0 ---> Cleaning xorg-xf86bigfontproto ---> Fetching xorg-xtrans ---> Attempting to fetch xtrans-1.2.6.tar.bz2 from http://xorg.freedesktop.org/archive/individual/lib/ ---> Verifying checksum(s) for xorg-xtrans ---> Extracting xorg-xtrans ---> Configuring xorg-xtrans ---> Building xorg-xtrans ---> Staging xorg-xtrans into destroot ---> Installing xorg-xtrans @1.2.6_0 ---> Activating xorg-xtrans @1.2.6_0 ---> Cleaning xorg-xtrans ---> Fetching xorg-libX11 ---> Attempting to fetch libX11-1.4.3.tar.bz2 from http://xorg.freedesktop.org/archive/individual/lib/ ---> Verifying checksum(s) for xorg-libX11 ---> Extracting xorg-libX11 ---> Configuring xorg-libX11 ---> Building xorg-libX11 ---> Staging xorg-libX11 into destroot ---> Installing xorg-libX11 @1.4.3_0 ---> Activating xorg-libX11 @1.4.3_0 ---> Cleaning xorg-libX11 ---> Fetching xorg-libXext ---> Attempting to fetch libXext-1.2.0.tar.bz2 from http://xorg.freedesktop.org/archive/individual/lib ---> Verifying checksum(s) for xorg-libXext ---> Extracting xorg-libXext ---> Configuring xorg-libXext ---> Building xorg-libXext ---> Staging xorg-libXext into destroot ---> Installing xorg-libXext @1.2.0_0 ---> Activating xorg-libXext @1.2.0_0 ---> Cleaning xorg-libXext ---> Fetching xorg-randrproto ---> Attempting to fetch randrproto-1.3.2.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto/ ---> Verifying checksum(s) for xorg-randrproto ---> Extracting xorg-randrproto ---> Configuring xorg-randrproto ---> Building xorg-randrproto ---> Staging xorg-randrproto into destroot ---> Installing xorg-randrproto @1.3.2_0 ---> Activating xorg-randrproto @1.3.2_0 ---> Cleaning xorg-randrproto ---> Fetching xorg-renderproto ---> Attempting to fetch renderproto-0.11.1.tar.bz2 from http://xorg.freedesktop.org/archive/individual/proto/ ---> Verifying checksum(s) for xorg-renderproto ---> Extracting xorg-renderproto ---> Configuring xorg-renderproto ---> Building xorg-renderproto ---> Staging xorg-renderproto into destroot ---> Installing xorg-renderproto @0.11.1_0 ---> Activating xorg-renderproto @0.11.1_0 ---> Cleaning xorg-renderproto ---> Fetching xrender ---> Attempting to fetch libXrender-0.9.6.tar.bz2 from http://www.x.org/archive/individual/lib/ ---> Verifying checksum(s) for xrender ---> Extracting xrender ---> Configuring xrender ---> Building xrender ---> Staging xrender into destroot ---> Installing xrender @0.9.6_0 ---> Activating xrender @0.9.6_0 ---> Cleaning xrender ---> Fetching xorg-libXrandr ---> Attempting to fetch libXrandr-1.3.1.tar.bz2 from http://xorg.freedesktop.org/archive/individual/lib/ ---> Verifying checksum(s) for xorg-libXrandr ---> Extracting xorg-libXrandr ---> Configuring xorg-libXrandr ---> Building xorg-libXrandr ---> Staging xorg-libXrandr into destroot ---> Installing xorg-libXrandr @1.3.1_0 ---> Activating xorg-libXrandr @1.3.1_0 ---> Cleaning xorg-libXrandr ---> Fetching libsdl ---> Attempting to fetch SDL-1.2.14.tar.gz from http://www.libsdl.org/release/ ---> Verifying checksum(s) for libsdl ---> Extracting libsdl ---> Applying patches to libsdl ---> Configuring libsdl ---> Building libsdl ---> Staging libsdl into destroot ---> Installing libsdl @1.2.14_9 ---> Activating libsdl @1.2.14_9 ---> Cleaning libsdl ---> Computing dependencies for git-core ---> Dependencies to be installed: curl curl-ca-bundle perl5 perl5.12 libidn p5-error rsync popt ---> Fetching perl5.12 ---> Attempting to fetch perl-5.12.3.tar.bz2 from http://www.cpan.org/src/5.0/ ---> Verifying checksum(s) for perl5.12 ---> Extracting perl5.12 ---> Applying patches to perl5.12 ---> Configuring perl5.12 ---> Building perl5.12 ---> Staging perl5.12 into destroot ---> Installing perl5.12 @5.12.3_1 ---> Activating perl5.12 @5.12.3_1 ---> Cleaning perl5.12 ---> Fetching perl5 ---> Verifying checksum(s) for perl5 ---> Extracting perl5 ---> Configuring perl5 ---> Building perl5 ---> Staging perl5 into destroot ---> Installing perl5 @5.12.3_1+perl5_12 ---> Activating perl5 @5.12.3_1+perl5_12 ---> Cleaning perl5 ---> Fetching curl-ca-bundle ---> Attempting to fetch curl-7.21.5.tar.bz2 from http://curl.haxx.se/download/ ---> Attempting to fetch certdata-1.74.txt from http://distfiles.macports.org/curl/ ---> Verifying checksum(s) for curl-ca-bundle ---> Extracting curl-ca-bundle ---> Applying patches to curl-ca-bundle ---> Configuring curl-ca-bundle ---> Building curl-ca-bundle ---> Staging curl-ca-bundle into destroot ---> Installing curl-ca-bundle @7.21.5_0 ---> Activating curl-ca-bundle @7.21.5_0 ---> Cleaning curl-ca-bundle ---> Fetching libidn ---> Attempting to fetch libidn-1.20.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/libidn ---> Verifying checksum(s) for libidn ---> Extracting libidn ---> Configuring libidn ---> Building libidn ---> Staging libidn into destroot ---> Installing libidn @1.20_0 ---> Activating libidn @1.20_0 ---> Cleaning libidn ---> Fetching curl ---> Verifying checksum(s) for curl ---> Extracting curl ---> Applying patches to curl ---> Configuring curl ---> Building curl ---> Staging curl into destroot ---> Installing curl @7.21.5_1+ssl ---> Activating curl @7.21.5_1+ssl ---> Cleaning curl ---> Fetching p5-error ---> Attempting to fetch Error-0.17016.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/CPAN/modules/by-module/Error ---> Verifying checksum(s) for p5-error ---> Extracting p5-error ---> Configuring p5-error ---> Building p5-error ---> Staging p5-error into destroot ---> Installing p5-error @0.17016_1 ---> Activating p5-error @0.17016_1 ---> Cleaning p5-error ---> Fetching popt ---> Attempting to fetch popt-1.16.tar.gz from http://rpm5.org/files/popt/ ---> Attempting to fetch popt-1.16.tar.gz from http://distfiles.macports.org/popt ---> Verifying checksum(s) for popt ---> Extracting popt ---> Configuring popt ---> Building popt ---> Staging popt into destroot ---> Installing popt @1.16_0 ---> Activating popt @1.16_0 ---> Cleaning popt ---> Fetching rsync ---> Attempting to fetch rsync-3.0.7.tar.gz from http://rsync.samba.org/ftp/rsync/ ---> Attempting to fetch rsync-3.0.7.tar.gz from http://rsync.samba.org/ftp/rsync/src/ ---> Verifying checksum(s) for rsync ---> Extracting rsync ---> Applying patches to rsync ---> Configuring rsync ---> Building rsync ---> Staging rsync into destroot ---> Installing rsync @3.0.7_1 ---> Activating rsync @3.0.7_1 ---> Cleaning rsync ---> Fetching git-core ---> Attempting to fetch git-1.7.4.4.tar.bz2 from http://www.kernel.org/pub/software/scm/git/ ---> Attempting to fetch git-manpages-1.7.4.4.tar.bz2 from http://www.kernel.org/pub/software/scm/git/ ---> Attempting to fetch git-htmldocs-1.7.4.4.tar.bz2 from http://www.kernel.org/pub/software/scm/git/ ---> Verifying checksum(s) for git-core ---> Extracting git-core ---> Applying patches to git-core ---> Configuring git-core ---> Building git-core ---> Staging git-core into destroot ---> Installing git-core @1.7.4.4_0+doc+python27 ---> Activating git-core @1.7.4.4_0+doc+python27 ---> Cleaning git-core ---> Computing dependencies for gnupg ---> Dependencies to be installed: libusb-compat libusb ---> Fetching libusb ---> Attempting to fetch libusb-1.0.8.tar.bz2 from http://downloads.sourceforge.net/libusb ---> Verifying checksum(s) for libusb ---> Extracting libusb ---> Configuring libusb ---> Building libusb ---> Staging libusb into destroot ---> Installing libusb @1.0.8_0 ---> Activating libusb @1.0.8_0 ---> Cleaning libusb ---> Fetching libusb-compat ---> Attempting to fetch libusb-compat-0.1.3.tar.bz2 from http://downloads.sourceforge.net/libusb ---> Verifying checksum(s) for libusb-compat ---> Extracting libusb-compat ---> Configuring libusb-compat ---> Building libusb-compat ---> Staging libusb-compat into destroot ---> Installing libusb-compat @0.1.3_0 ---> Activating libusb-compat @0.1.3_0 ---> Cleaning libusb-compat ---> Fetching gnupg ---> Attempting to fetch gnupg-1.4.11.tar.bz2 from ftp://gd.tuwien.ac.at/privacy/gnupg/gnupg ---> Verifying checksum(s) for gnupg ---> Extracting gnupg ---> Configuring gnupg ---> Building gnupg ---> Staging gnupg into destroot ---> Installing gnupg @1.4.11_0 ---> Activating gnupg @1.4.11_0 ---> Cleaning gnupg 居然!!你真的手贱点开了,于是可能被你发现了。。。开始装的XCode3.0不行。。。 只好装了XCode3.1.4再来过。。。
如果你是Mac OS X 10.4版本的话,还要安装个bison
% POSIXLY_CORRECT=1 sudo port install bison
下面要把gmake 3.82还原到3.81,否则之后编译源码会出错:
$ sudo vim /opt/local/etc/macports/sources.conf
然后在rsync那行的上面一行加上
file:///Users/Shared/dports
之后按这个步骤来就行了:
$ mkdir /Users/Shared/dports $ cd /Users/Shared/dports/ $ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/ A devel/gmake/Portfile Checked out revision 50980. $ portindex /Users/Shared/dports Creating port index in /Users/Shared/dports Adding port devel/gmake Total number of ports parsed: 1 Ports successfully parsed: 1 Ports failed: 0 Up-to-date ports skipped: 0 $ sudo port install gmake @3.81 ---> Computing dependencies for gmake ---> Fetching gmake ---> Attempting to fetch make-3.81.tar.bz2 from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/make ---> Verifying checksum(s) for gmake ---> Extracting gmake ---> Configuring gmake ---> Building gmake ---> Staging gmake into destroot ---> Installing gmake @3.81_0 ---> Deactivating gmake @3.82_0 ---> Activating gmake @3.81_0 ---> Cleaning gmake
检查一下gmake版本,看到版本号是3.81就对了:
$ gmake --version GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for i386-apple-darwin9.8.0
于是最后下载Android源码前的最后一步就是,修改文件标识符限制:
由于Mac OS 默认将同时打开的文件标识符数量限制得太小,并行编译处理时可能会超出这个限制。
所以在 ~/.bash_profile 里加上这么一段:
# set the number of open files to be 1024 ulimit -S -n 1024
3.1. 安装Git Repo
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl http://android.git.kernel.org/repo > ~/bin/repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17451 100 17451 0 0 39190 0 --:--:-- --:--:-- --:--:-- 57029
$ chmod a+x ~/bin/repo
3.2. 初始化Git Repo
进入开始时挂载的镜像硬盘,建立一个工作目录:
$cd /Volumes/AndroidDisk $makedir WorkingSpace/ $cd Working Space/
在此目录下初始化repo,其间会提示你输入自己的名字和google account邮箱地址:
$ repo init -u git://android.git.kernel.org/platform/manifest.git
最后,
$ repo init -u git://android.git.kernel.org/platform/manifest.git
如果你对git比较熟悉的话,后面就不用啰嗦啦。比如,
设定其它的branch (例如froyo)
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo
同步文件:
$ repo sync
(开始下载repo里的文件——源码。于是似乎睡一觉的时间又到了。。)
再import一个GPG public key,
$ gpg --import
以下是官网给出的key,输入完按Ctrl+D结束:
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv
aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k
cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX
gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI
2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl
QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up
hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk
C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX
LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+
OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M
pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----
如果你愿意的话还可以验证一下随便哪个Tag:
$ git tag -v TAG_NAME
小配置一下,用模拟器就行了。
$ . build/envsetup.sh $ lunch generic-eng
开始编译,留log吧!
$ make -j2 2>&1 | tee buildlog.txt
j后面的那个数字,官方解释是所用硬件线程数的1-2倍。
然后就可以慢慢等了。。。留图纪念,千万Don’t Panic哦~
临时试一下的话,就临时配个环境变量:
$ export PATH=$PATH:/Volumes/AndroidDisk/WorkingSpace/out/host/darwin-x86/bin/ $ export ANDROID_PRODUCT_OUT=/Volumes/AndroidDisk/WorkingSpace/out/target/product/generic/
运行模拟器:
$ emulator
哎,终于出现了模拟的Android系统!好累。。(电脑酱:你累个毛,人家才累呢!)
下次再写个Android源码分析吧。不过好像写的人挺多了已经,不知能不能弄出点什么新意来⋯⋯





mac os x10.7 下编译android 源码出现问题。
提示我需要10.4sdk,看了目录下面只有10.6、10.7 的sdk,
能有+gtalk探讨下
我在revert gmake3.82的时候,每次打完命令只显示
—> Computing dependencies for gmake
—> Cleaning gmake
然后用gmake -version发现还是3.82,反复好几次都这样,请问这是什么原因。
请问,在第四步编译的那里,出现下面的错误怎么办?
ho-solomatoMacBook-Pro:WORKING_DIRECTORY hosolo$ lunch generic-eng
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=darwin
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
ho-solomatoMacBook-Pro:WORKING_DIRECTORY hosolo$ make -j4
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=darwin
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
Checking build tools versions…
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: java version “1.6.0_26″.
The correct version is: 1.5.
Please follow the machine setup instructions at
http://source.android.com/download
************************************************************
build/core/main.mk:111: *** stop. Stop.
借鉴了,呵呵
看完了,乃要从底层入手做东西了呀。
OS X身为UNIX认证的系统竟然默认不是case-sensitive。。。。。
File System是OS里很外围的东西啦其实~
well, anyway, it depends… (摊手
喂~这个代码的meta怎么实现?神马插件?