|
| 1 | +官方文档:https://source.android.google.cn/setup/start |
| 2 | + |
| 3 | +清华源:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/ |
| 4 | + |
| 5 | +参考:https://www.jianshu.com/p/a7b90c3b5c76 |
| 6 | + |
| 7 | +1. 安装 Repo |
| 8 | + |
| 9 | + ```shell |
| 10 | + brew install repo |
| 11 | + ``` |
| 12 | + |
| 13 | +2. 使用每月更新的初始化包 |
| 14 | + |
| 15 | + ```shell |
| 16 | + wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包 |
| 17 | + tar xf aosp-latest.tar |
| 18 | + cd AOSP # 解压得到的 AOSP 工程目录 |
| 19 | + # 这时 ls 的话什么也看不到,因为只有一个隐藏的 .repo 目录 |
| 20 | + repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-12.0.0_r28 |
| 21 | + # 罗升阳 android-2.3_r1 |
| 22 | + repo sync # 正常同步一遍即可得到完整目录 |
| 23 | + # 或 repo sync -l 仅checkout代码 |
| 24 | + ``` |
| 25 | + |
| 26 | +3. 编译失败~ |
| 27 | + |
| 28 | +------------------------ |
| 29 | + |
| 30 | +[如何在 macOS 上安装虚拟机软件 VMware Fusion Player (个人版免费)](https://blog.csdn.net/wuyujin1997/article/details/128776714) |
| 31 | + |
| 32 | +参考[VMware Fusion在M1上安装Ubuntu虚拟机](https://www.bilibili.com/video/av421832011) |
| 33 | + |
| 34 | +Ubuntu arm版本镜像:https://ubuntu.com/download/server/arm |
| 35 | + |
| 36 | +```shell |
| 37 | +# 可以考虑换源 |
| 38 | +sudo apt-get update |
| 39 | +sudo apt install ubuntu-desktop |
| 40 | +reboot |
| 41 | +# Ubuntu 安装 VMware Tools |
| 42 | +sudo apt install open-vm-tools |
| 43 | +sudo apt install open-vm-tools-desktop |
| 44 | +``` |
| 45 | + |
| 46 | +```shell |
| 47 | +# 这一段是准备工作,无所谓,Ubuntu最新版已经是python3 |
| 48 | +# 安装git: |
| 49 | +sudo apt install git |
| 50 | +# 安装依赖工具: |
| 51 | +sudo apt install git-core libssl-dev libffi-dev gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev libz-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip |
| 52 | +# 下载Python3: |
| 53 | +cd Downloads |
| 54 | +wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz |
| 55 | +# 解压Python3: |
| 56 | +tar xvf Python-3.7.1.tgz |
| 57 | +# 编译与安装Python3: |
| 58 | +./configure |
| 59 | +sudo make install |
| 60 | +# 配置update-alternatives: |
| 61 | +sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2 |
| 62 | +sudo update-alternatives --install /usr/bin/python python python3的安装地址(/usr/local/bin/python3.7) 3(权重号) |
| 63 | +# 选择Python版本: |
| 64 | +sudo update-alternatives --config python |
| 65 | +``` |
| 66 | + |
| 67 | +AOSP官方地址:https://source.android.google.cn/setup/build/downloading |
| 68 | +中科大镜像:https://mirrors.ustc.edu.cn/help/aosp.html |
| 69 | +清华镜像:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/ |
| 70 | + |
| 71 | +教程使用中科大初始同步方法 2安装: |
| 72 | + |
| 73 | +```shell |
| 74 | +mkdir ~/bin |
| 75 | +cd ~/bin |
| 76 | +PATH=~/bin:$PATH |
| 77 | +curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo |
| 78 | +chmod a+x ~/bin/repo |
| 79 | +mkdir ~/WORKING_DIRECTORY |
| 80 | +cd ~/WORKING_DIRECTORY |
| 81 | +repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest |
| 82 | +# 可以编译 Android 8 |
| 83 | +repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.3.1_r1 |
| 84 | +# 使用清华源 |
| 85 | +repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-2.3.1_r1 |
| 86 | +repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.1_r1 |
| 87 | +repo sync |
| 88 | +``` |
| 89 | + |
| 90 | +#### 错误一 |
| 91 | + |
| 92 | +如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo,把 REPO_URL 一行替换成下面的: REPO_URL = 'https://gerrit-googlesource.proxy.ustclug.org/git-repo' |
| 93 | + |
| 94 | +#### 错误二 |
| 95 | + |
| 96 | +如果提示无法进行SSL证书校验,执行: |
| 97 | + |
| 98 | +错误:error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed |
| 99 | + |
| 100 | +```shell |
| 101 | +git config --global http.sslverify false |
| 102 | +git config --global https.sslverify false |
| 103 | +``` |
| 104 | + |
| 105 | +#### 错误三 |
| 106 | + |
| 107 | +如果出现git身份不存在: |
| 108 | + |
| 109 | +```shell |
| 110 | +git config --global user.email "[email protected]" |
| 111 | +git config --global user.name sec |
| 112 | +``` |
| 113 | + |
| 114 | +#### 错误四 |
| 115 | + |
| 116 | +ubuntu /usr/bin/env: python : no such file or directory |
| 117 | + |
| 118 | +```shell |
| 119 | +whereis python3 |
| 120 | +sudo ln -s /usr/bin/python3 /usr/bin/python |
| 121 | +``` |
| 122 | + |
| 123 | +----------- |
| 124 | + |
| 125 | +------------ |
| 126 | + |
| 127 | +### 自定义ROM刷机实战 |
| 128 | + |
| 129 | +[wget 下载官方驱动](https://developers.google.cn/android/drivers),解压,chmod +x ,运行 shell 脚本 |
| 130 | + |
| 131 | +```shell |
| 132 | +make -j 4 |
| 133 | +adb devices |
| 134 | +# 进入Bootloader模式:(解BL锁) |
| 135 | +# https://source.android.google.cn/setup/build/running 查看如何解锁引导加载程序 |
| 136 | +# 可以淘宝购买已解锁的设备,或者去小米官网看如何OEM解锁 |
| 137 | +adb reboot bootloader |
| 138 | +# 查看连接设备: |
| 139 | +fastboot devices |
| 140 | +# 正式刷机 |
| 141 | +fastboot flashall -w |
| 142 | +``` |
| 143 | + |
| 144 | +```shell |
| 145 | +# 编译 Android 12 源码先设置交换空间再正常编译 |
| 146 | +# 配置环境 |
| 147 | +source build/envsetup.sh |
| 148 | +# 选择要编译的选项: |
| 149 | +lunch |
| 150 | +# 执行编译 |
| 151 | +make -j 4 |
| 152 | +# 交换空间 |
| 153 | +swapon -s |
| 154 | +# 停止交换空间 |
| 155 | +sudo swapoff /swapfile |
| 156 | +sudo rm /swapfile |
| 157 | +sudo fallocate -l 20G /swapfile |
| 158 | +ls -l /swapfile |
| 159 | +sudo mkswap /swapfile |
| 160 | +sudo swapon /swapfile |
| 161 | +free -m |
| 162 | +``` |
0 commit comments