1. 前提:首先用mac的磁盘工具将mac的文件系统改一下,不然会报错
20:14:33 Failed to increase file limit: invalid argument
20:15:20 ************************************************************
20:15:20 You are building on a case-insensitive filesystem.
20:15:20 Please move your source tree to a case-sensitive filesystem.
20:15:20 ************************************************************
20:15:20 Case-insensitive filesystems not supported
修改如下:
或者用命令修改也可以
2. 配置aosp环境 & 下载代码
mkdir AOSP && cd AOSP/
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-13.0.0_r1
repo sync
下载速度取决于网络,我下载了4个小时
3. 编译
首先编译可能遇到问题
19:08:29 You are building on a machine with 8GB of RAM
19:08:29
19:08:29 The minimum required amount of free memory is around 16GB,
19:08:29 and even with that, some configurations may not work.
19:08:29
19:08:29 If you run into segfaults or other errors, try reducing your
19:08:29 -j value.
解决此报错问题的方法是修改编译配置
vi build/soong/ui/build/build.go
搜索报错的内容,将16改成你的电脑内存配置即可
source build/envsetup.sh
lunch aosp_flame-userdebug
cd external/tinyxml2/
mm
如果遇到too many open files,主要原因是打开了太多的文件,系统资源吃紧,看一下系统
launchctl limit
在 /Library/LaunchDaemos 目录下,新建两个文件:limit.maxfiles.plist 和 limit.maxproc.plist
,并且修改两个文件的用户为 root,内容如下,添加完后重启电脑生效:
limit.maxfiles.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>65536</string>
<string>65536</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
limit.maxproc.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>2048</string>
<string>2048</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>