Run Android emulator without GUI (headless Android)

馋奶兔 提交于 2019-11-26 20:14:17

问题


How can I run emulator without GUI (headless Android)?

My requirement is to run the headless Android on the emulator. Is it correct if I use ro.config.headless 1? Or disable zygote?


回答1:


Android Emulator 28.1.8 now supports running the emulator in headless mode (emulator-headless): https://androidstudio.googleblog.com/2019/02/emulator-2818-canary.html




回答2:


One of the options to achieve that is to stop zygote service when an emulator running. When stopping the zygote process (aka app_process) all of the system services, that were forked from zygote at system boot, shuts down. Only a few native system services will be running. The emulator's display should show the startup logo (or animation).

The steps for stopping zygote are as follows:

  • adb shell
  • su (most of emulator images have /system/xbin/su)
  • stop zygote

After that you can explore how less services are running with service list. Critical for Android Runtime services will be stopped, e.g.

activity: [] // ActivityManager
package: [] // PackageManager
display: [] // DisplayManager
...

To start zygote execute:

  • start zygote

Note: with the @CommonsWare's solution you are still going to have zygote and most of the Android system services running.



来源:https://stackoverflow.com/questions/20869067/run-android-emulator-without-gui-headless-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!