1 PC环境
非模拟器运动
2 源码下载
2.1 工具安装
- git
sudo apt-get install git
- curl下载工具
sudo apt-get install curl
- repo下载配置,使用中科大的源
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
## 如果上述 URL 不可访问,可以用下面的:
## curl -sSL 'https://gerrit-googlesource.proxy.ustclug.org/git-repo/+/master/repo?format=TEXT' |base64 -d > ~/bin/repo
chmod a+x ~/bin/repo
修改repo
# 编辑 ~/bin/repo,把 REPO_URL 一行替换成下面的:
# REPO_URL = 'https://gerrit-googlesource.proxy.ustclug.org/git-repo'
vim repo
- python
sudo apt-get install python
2.2 下载源码
- 建立源码存放目录
mkdir aosp
cd aosp
- git账号配置
git config --global user.email "ericli2wang@gmail.com"
git config --global user.name "arvin"
- 初始化仓库 android-11.0.0_r17
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-11.0.0_r17
- 同步源码
repo sync
-
下载完成结果
3 编译源码
3.1 环境配置
参考官方文档https://source.android.google.cn/setup/build/initializing
sudo apt-get install openjdk-8-jdk
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
3.2 驱动下载
参考https://source.android.google.cn/setup/build/downloading
下载地址:https://developers.google.cn/android/drivers
下载完成后放入到源码根目录(aosp)下解压
tar -zxvf google_devices-redfin-rd1a.200810.020-3940ace1.tgz
tar -zxvf qcom-redfin-rd1a.200810.020-e99cf7f8.tgz
得到
分别运行脚本即可
对应的文件已经在aosp/vendor中生成
3.3 编译
- 初始化环境
source build/envsetup.sh
// 编译前删除build文件夹A
make clobber
- 选择编译目标 lunch
arvin@arvin-System-Product-Name:~/aosp$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_blueline-userdebug
4. aosp_blueline_car-userdebug
5. aosp_bonito-userdebug
6. aosp_bonito_car-userdebug
7. aosp_car_arm-userdebug
8. aosp_car_arm64-userdebug
9. aosp_car_x86-userdebug
10. aosp_car_x86_64-userdebug
11. aosp_cf_arm64_auto-userdebug
12. aosp_cf_arm64_phone-userdebug
13. aosp_cf_x86_64_phone-userdebug
14. aosp_cf_x86_auto-userdebug
15. aosp_cf_x86_phone-userdebug
16. aosp_cf_x86_tv-userdebug
17. aosp_coral-userdebug
18. aosp_coral_car-userdebug
19. aosp_crosshatch-userdebug
20. aosp_crosshatch_car-userdebug
21. aosp_flame-userdebug
22. aosp_flame_car-userdebug
23. aosp_sargo-userdebug
24. aosp_sunfish-userdebug
25. aosp_taimen-userdebug
26. aosp_trout_arm64-userdebug
27. aosp_trout_x86-userdebug
28. aosp_walleye-userdebug
29. aosp_walleye_test-userdebug
30. aosp_x86-eng
31. aosp_x86_64-eng
32. arm_krait-eng
33. arm_v7_v8-eng
34. armv8-eng
35. armv8_kryo385-eng
36. beagle_x15-userdebug
37. beagle_x15_auto-userdebug
38. car_x86_64-userdebug
39. db845c-userdebug
40. fuchsia_arm64-eng
41. fuchsia_x86_64-eng
42. hikey-userdebug
43. hikey64_only-userdebug
44. hikey960-userdebug
45. hikey960_tv-userdebug
46. hikey_tv-userdebug
47. pixel3_mainline-userdebug
48. poplar-eng
49. poplar-user
50. poplar-userdebug
51. qemu_trusty_arm64-userdebug
52. silvermont-eng
53. uml-userdebug
54. yukawa-userdebug
55. yukawa_sei510-userdebug
这里我们选择 aosp_x86-eng输入30
- 开始编译
make -j6
- 运行虚拟机
emulator
4 FAQ
4.1 /dev/kvm device : permision denied
当前用户无kvm权限
sudo usermod -a -G kvm 用户名
4.2 编译完成后虚拟机启动进入到桌面后crash
更新驱动
sudo ubuntu-drivers autoinstall