如何在没有用户交互的情况下创建 AVD?

How to create AVD without user interaction?

我想通过命令行在远程机器上创建 AVD。我在两端都使用 ubuntu 机器。

我正在使用 android create avd -n <name> -t <target> 命令创建 AVD。

但是,它适用于用户交互询问:

Android 4.0.3 is a basic Android platform.
Do you wish to create a custom hardware profile [no]

它等待用户交互。如何使用无头模式创建 AVD。在某些情况下我可能需要自定义 AVD(在其他情况下我需要提供 YES 作为答案 Enter 键就可以)?

我使用 expect 命令行自动化库解决了这个问题。 您可以在 https://github.com/saurabhjinturkar/avd_creator

看到实现