下载专用二进制文件

暂时还搞不清楚这个二进制文件,第一次没有下载二进制文件,启动模拟器不成功,后来下载了二进制文件,并在源码目录中解压执行,再编译后,启动模拟器就成功啦。

编译Android源码,并用模拟器启动编译好的镜像_android

我选择的是这两个文件:

编译Android源码,并用模拟器启动编译好的镜像_二进制文件_02

编译Android源码,并用模拟器启动编译好的镜像_编译类型_03

编译Android源码,并用模拟器启动编译好的镜像_编译类型_04

编译

进入Android源码目录,首先清除之前的编译:

make clobber

然后设置环境:

source build/envsetup.sh

选择编译的文件,直接输入命令:

lunch

BUILDTYPE 是以下类型之一:

编译类型 使用情况
user 权限受限;适用于生产环境
userdebug 与“user”类似,但具有 root 权限和可调试性;是进行调试时的首选编译类型
eng 具有额外调试工具的开发配置

如下:

gs@aigo:~/02_android/android9.0.0_35$ 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_crosshatch-userdebug
     19. aosp_blueline-userdebug
     20. aosp_cf_x86_auto-userdebug
     21. aosp_cf_x86_phone-userdebug
     22. aosp_cf_x86_tablet-userdebug
     23. aosp_cf_x86_tablet_3g-userdebug
     24. aosp_cf_x86_tv-userdebug
     25. aosp_cf_x86_wear-userdebug
     26. aosp_cf_x86_64_auto-userdebug
     27. aosp_cf_x86_64_phone-userdebug
     28. aosp_cf_x86_64_tablet-userdebug
     29. aosp_cf_x86_64_tablet_3g-userdebug
     30. aosp_cf_x86_64_tv-userdebug
     31. aosp_cf_x86_64_wear-userdebug
     32. cf_x86_auto-userdebug
     33. cf_x86_phone-userdebug
     34. cf_x86_tablet-userdebug
     35. cf_x86_tablet_3g-userdebug
     36. cf_x86_tv-userdebug
     37. cf_x86_wear-userdebug
     38. cf_x86_64_phone-userdebug
     39. cf_x86_64_tablet-userdebug
     40. cf_x86_64_tablet_3g-userdebug
     41. cf_x86_64_tv-userdebug
     42. cf_x86_64_wear-userdebug
     43. aosp_marlin-userdebug
     44. aosp_marlin_svelte-userdebug
     45. aosp_sailfish-userdebug
     46. aosp_walleye-userdebug
     47. aosp_walleye_test-userdebug
     48. aosp_taimen-userdebug
     49. hikey-userdebug
     50. hikey64_only-userdebug
     51. hikey960-userdebug

Which would you like? [aosp_arm-eng] 6

备注:我电脑的环境是9700k,ubuntu1804,我先选择了1和2都不行,启动emulator后,模拟器一直现实的画面是android,估计是卡住了,后来选择了6后,在模拟器中可以运行。

编译:

make -j8
启动模拟器

编译成功后,在命令中输入:

emulator

模拟器运行正常,截图:

编译Android源码,并用模拟器启动编译好的镜像_android_05

 

这下就可以愉快的调试代码啦,

 

 

本文参考的文章:

https://source.android.google.cn/setup/building?hl=zh-cn

emulator命令详解:javascript:void(0)