运行没有 GUI 的 Android 模拟器(无头 Android)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20869067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run Android emulator without GUI (headless Android)
提问by Android0077
How can I run emulator without GUI (headless Android)?
如何在没有 GUI(无头 Android)的情况下运行模拟器?
My requirement is to run the headless Androidon the emulator. Is it correct if I use ro.config.headless 1
? Or disable zygote?
我的要求是在模拟器上运行无头Android。如果我使用它是否正确ro.config.headless 1
?或禁用合子?
回答by marius bardan
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
Android Emulator 28.1.8 现在支持在无头模式 ( emulator-headless
)下运行模拟器:https: //androidstudio.googleblog.com/2019/02/emulator-2818-canary.html
回答by Onik
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).
实现这一目标的方法之一是zygote
在模拟器运行时停止服务。当停止zygote
进程(又名app_process
)时,所有zygote
在系统启动时分叉的系统服务都会关闭。只有少数本地系统服务会运行。模拟器的显示屏应显示启动徽标(或动画)。
The steps for stopping zygote
are as follows:
停止步骤zygote
如下:
adb shell
su
(most of emulator images have/system/xbin/su
)stop zygote
adb shell
su
(大多数模拟器图像都有/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.
之后,您可以探索使用service list
. Android 运行时的关键服务将被停止,例如
activity: [] // ActivityManager
package: [] // PackageManager
display: [] // DisplayManager
...
To start zygote
execute:
开始zygote
执行:
start zygote
start zygote
Note: with the @CommonsWare's solution you are still going to have zygote
and most of the Androidsystem services running.
注意:使用@CommonsWare 的解决方案,您仍然可以运行zygote
大多数Android系统服务。