Android AOSP资源的下载
Android Studio 导入系统源码并对源码进行debug调试
安装 jdk8
sudo apt-get update
sudo apt-get install openjdk-8-jdk
安装以下依赖包
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
初始化环境
进入aosp目录执行
source build/envsetup.sh
// 编译前删除build文件夹A
make clobber
选择编译目标
lunch
会出现如下内容
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_mips-eng
4. aosp_mips64-eng
5. aosp_x86-eng
6. aosp_x86_64-eng
7. aosp_car_arm-userdebug
8. aosp_car_arm64-userdebug
9. aosp_car_x86-userdebug
10. aosp_car_x86_64-userdebug
11. mini_emulator_arm64-userdebug
12. m_e_arm-userdebug
13. m_e_mips64-eng
14. m_e_mips-userdebug
15. mini_emulator_x86_64-userdebug
16. mini_emulator_x86-userdebug
17. uml-userdebug
18. aosp_cf_x86_auto-userdebug
19. aosp_cf_x86_phone-userdebug
20. aosp_cf_x86_tablet-userdebug
21. aosp_cf_x86_tablet_3g-userdebug
22. aosp_cf_x86_tv-userdebug
23. aosp_cf_x86_wear-userdebug
24. aosp_cf_x86_64_auto-userdebug
25. aosp_cf_x86_64_phone-userdebug
26. aosp_cf_x86_64_tablet-userdebug
27. aosp_cf_x86_64_tablet_3g-userdebug
28. aosp_cf_x86_64_tv-userdebug
29. aosp_cf_x86_64_wear-userdebug
30. cf_x86_auto-userdebug
31. cf_x86_phone-userdebug
32. cf_x86_tablet-userdebug
33. cf_x86_tablet_3g-userdebug
34. cf_x86_tv-userdebug
35. cf_x86_wear-userdebug
36. cf_x86_64_auto-userdebug
37. cf_x86_64_phone-userdebug
38. cf_x86_64_tablet-userdebug
39. cf_x86_64_tablet_3g-userdebug
40. cf_x86_64_tv-userdebug
41. cf_x86_64_wear-userdebug
42. aosp_marlin-userdebug
43. aosp_marlin_svelte-userdebug
44. aosp_sailfish-userdebug
45. aosp_walleye-userdebug
46. aosp_walleye_test-userdebug
47. aosp_taimen-userdebug
48. hikey-userdebug
49. hikey64_only-userdebug
50. hikey960-userdebug
Which would you like? [aosp_arm-eng]
- user:用来正式发布到市场的版本,权限受限,如没有 root 权限,不能 dedug,adb默认处于停用
- userdebug:在user版本的基础上开放了 root 权限和 debug 权限,adb默认处于启用状态。一般用于调试真机。
- eng:开发工程师的版本,拥有最大的权限(root等),具有额外调试工具的开发配置。一般用于模拟器。
指定编译的目标:
lunch aosp_x86-eng
开始编译
make -j6
编译的过程中遇到这个问题:
prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++.real: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
解决方法:
sudo apt-get install libncurses*
终于编译成功了!!!
如果想重新编译Android项目,如果想做清理工作,可以执行如下操作:
1、在源码目录的根目录下,执行 make clean;
2、进到源码的\linux\kernel\目录下,执行make mrproper;
3、再退回到根目录,执行source build/envsetup.sh, lunch, make -j6.
编译的得到的内容
out/target/product/generic_x86/ 这个目录下会生成三个重要的文件
system.img->Android系统镜像,系统的主要目录和文件
usedata.img->用户镜像,用来存放用户的数据
ramdisk.img->根文件系统镜像
启动虚拟机
source build/envsetup.sh
lunch 6
export PATH=$PATH:~/andrfoid9/out/host/linux-x86/bin
export ANDROID_PRODUCT_OUT=~/android9/out/target/product/generic_x86
emulator
如果是刚编译完可以直接执行
export PATH=$PATH:~/andrfoid9/out/host/linux-x86/bin
export ANDROID_PRODUCT_OUT=~/android9/out/target/product/generic_x86
emulator
感谢
https://blog.csdn.net/itachi85/article/details/89038370?spm=1001.2014.3001.5501