android7.0 来临,忍不住去下载源码玩玩,但是使用网上的攻略下载会出现各种各样的问题,现在这做一些修正,亲测有效。话不多说,一起来玩。
当然,开始是没问题啦,所有步骤就直接copy了,嗯,因为我比较懒,哈哈:
1.初始化安装环境:
A。建立大小写敏感硬盘镜像:
步骤如下:
Disk Utility –> New Image,随便取个名字,这里用AndroidDisk,60g吧,亲测40g 下满 然后还有文件没有拉下来,所以别纠结了,果断提升容量,然后注意选成Mac OS Extended (Case-sensitive, Journaled), –> Create
记住保存路劲为
~/AndroidDisk.dmg
B。挂载镜像:
使用命令:
hdiutil attach ~/AndroidDisk.dmg -mountpoint /Volumes/android
Google的官网上推荐把这行加到~/.bash_profile里,这样以后每次用mountAndroid命令就行了。
# mount the android file image function mountAndroid { hdiutil attach ~/AndroidDisk.dmg -mountpoint /Volumes/android; }
(记住路径和文件名的正确书写)
C。安装Xcode和MacPorts:
Xcode不用多说了,MacPorts从http://www.macports.org/install.php下载:
安装MacPorts之前需要确认环境变量PATH中,/opt/local/bin出现在/usr/bin之前,可以运行一下这行来确认:
$ echo $PATH
否则,就运行一下:
$ export PATH=/opt/local/bin:$PATH
并把上面那行加在~/.bash_profile里。
D。从MacPorts安装make, git, and GPG packages:
$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
如果你是Mac OS X 10.4版本的话,还要安装个bison
$ POSIXLY_CORRECT=1 sudo port install bison
$ sudo vim /opt/local/etc/macports/sources.conf
然后在rsync那行的上面一行加上
file:///Users/Shared/dport
之后按这个步骤来就行了:
$ mkdir /Users/Shared/dports
$ cd /Users/Shared/dports/
$ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
$ portindex /Users/Shared/dports
安装3.81版的:
$ sudo port install gmake @3.81
检查一下gmake版本,看到版本号是3.81就对了:
$ gmake --version
于是最后下载Android源码前的最后一步就是,修改文件标识符限制:
由于Mac OS 默认将同时打开的文件标识符数量限制得太小,并行编译处理时可能会超出这个限制。所以在 ~/.bash_profile 里加上这么一段:
# set the number of open files to be 1024
ulimit -S -n 1024
那么到了这步之后,网上的攻略就会出现一些误差,在此更正,亲测哦:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo//就这啦,下载几个repo都没发愉快的玩耍,还是这个地址有效
$ chmod a+x ~/bin/repo
初始化Git Repo进入开始时挂载的镜像硬盘,建立一个工作目录:
$cd /Volumes/AndroidDisk
$makedir WorkingSpace/
$cd Working Space/
$ repo init -u https://android.googlesource.com/platform/manifest
以下是6.0及7.0的版本咯:
[new branch] android-6.0.0_r1 -> origin/android-6.0.0_r1
* [new branch] android-6.0.0_r11 -> origin/android-6.0.0_r11
* [new branch] android-6.0.0_r12 -> origin/android-6.0.0_r12
* [new branch] android-6.0.0_r13 -> origin/android-6.0.0_r13
* [new branch] android-6.0.0_r2 -> origin/android-6.0.0_r2
* [new branch] android-6.0.0_r23 -> origin/android-6.0.0_r23
* [new branch] android-6.0.0_r24 -> origin/android-6.0.0_r24
* [new branch] android-6.0.0_r25 -> origin/android-6.0.0_r25
* [new branch] android-6.0.0_r26 -> origin/android-6.0.0_r26
* [new branch] android-6.0.0_r3 -> origin/android-6.0.0_r3
* [new branch] android-6.0.0_r4 -> origin/android-6.0.0_r4
* [new branch] android-6.0.0_r41 -> origin/android-6.0.0_r41
* [new branch] android-6.0.0_r5 -> origin/android-6.0.0_r5
* [new branch] android-6.0.0_r6 -> origin/android-6.0.0_r6
* [new branch] android-6.0.0_r7 -> origin/android-6.0.0_r7
* [new branch] android-6.0.1_r1 -> origin/android-6.0.1_r1
* [new branch] android-6.0.1_r10 -> origin/android-6.0.1_r10
* [new branch] android-6.0.1_r11 -> origin/android-6.0.1_r11
* [new branch] android-6.0.1_r12 -> origin/android-6.0.1_r12
* [new branch] android-6.0.1_r13 -> origin/android-6.0.1_r13
* [new branch] android-6.0.1_r16 -> origin/android-6.0.1_r16
* [new branch] android-6.0.1_r17 -> origin/android-6.0.1_r17
* [new branch] android-6.0.1_r18 -> origin/android-6.0.1_r18
* [new branch] android-6.0.1_r20 -> origin/android-6.0.1_r20
* [new branch] android-6.0.1_r21 -> origin/android-6.0.1_r21
* [new branch] android-6.0.1_r22 -> origin/android-6.0.1_r22
* [new branch] android-6.0.1_r24 -> origin/android-6.0.1_r24
* [new branch] android-6.0.1_r25 -> origin/android-6.0.1_r25
* [new branch] android-6.0.1_r26 -> origin/android-6.0.1_r26
* [new branch] android-6.0.1_r27 -> origin/android-6.0.1_r27
* [new branch] android-6.0.1_r28 -> origin/android-6.0.1_r28
* [new branch] android-6.0.1_r3 -> origin/android-6.0.1_r3
* [new branch] android-6.0.1_r30 -> origin/android-6.0.1_r30
* [new branch] android-6.0.1_r31 -> origin/android-6.0.1_r31
* [new branch] android-6.0.1_r32 -> origin/android-6.0.1_r32
* [new branch] android-6.0.1_r33 -> origin/android-6.0.1_r33
* [new branch] android-6.0.1_r4 -> origin/android-6.0.1_r4
* [new branch] android-6.0.1_r40 -> origin/android-6.0.1_r40
* [new branch] android-6.0.1_r41 -> origin/android-6.0.1_r41
* [new branch] android-6.0.1_r42 -> origin/android-6.0.1_r42
* [new branch] android-6.0.1_r43 -> origin/android-6.0.1_r43
* [new branch] android-6.0.1_r45 -> origin/android-6.0.1_r45
* [new branch] android-6.0.1_r46 -> origin/android-6.0.1_r46
* [new branch] android-6.0.1_r47 -> origin/android-6.0.1_r47
* [new branch] android-6.0.1_r48 -> origin/android-6.0.1_r48
* [new branch] android-6.0.1_r49 -> origin/android-6.0.1_r49
* [new branch] android-6.0.1_r5 -> origin/android-6.0.1_r5
* [new branch] android-6.0.1_r50 -> origin/android-6.0.1_r50
* [new branch] android-6.0.1_r51 -> origin/android-6.0.1_r51
* [new branch] android-6.0.1_r52 -> origin/android-6.0.1_r52
* [new branch] android-6.0.1_r53 -> origin/android-6.0.1_r53
* [new branch] android-6.0.1_r54 -> origin/android-6.0.1_r54
* [new branch] android-6.0.1_r55 -> origin/android-6.0.1_r55
* [new branch] android-6.0.1_r56 -> origin/android-6.0.1_r56
* [new branch] android-6.0.1_r57 -> origin/android-6.0.1_r57
* [new branch] android-6.0.1_r58 -> origin/android-6.0.1_r58
* [new branch] android-6.0.1_r59 -> origin/android-6.0.1_r59
* [new branch] android-6.0.1_r60 -> origin/android-6.0.1_r60
* [new branch] android-6.0.1_r61 -> origin/android-6.0.1_r61
* [new branch] android-6.0.1_r62 -> origin/android-6.0.1_r62
* [new branch] android-6.0.1_r63 -> origin/android-6.0.1_r63
* [new branch] android-6.0.1_r7 -> origin/android-6.0.1_r7
* [new branch] android-6.0.1_r8 -> origin/android-6.0.1_r8
* [new branch] android-6.0.1_r9 -> origin/android-6.0.1_r9
* [new branch] android-7.0.0_r1 -> origin/android-7.0.0_r1