简体   繁体   English

如何根据AVD Manager中的设备定义从命令行创建AVD?

[英]How can I create an AVD from the command line based on the device definitions in the AVD Manager?

In the AVD Manager gui I see a list of Device Definitions, these make it easy to provision a device with given settings. 在AVD Manager gui中,我看到了一个设备定义列表,这些设备可以很容易地为设备配置给定的设置。

When I use android list targets I get a different set of results from the device definitions. 当我使用android list targets我从设备定义中获得了一组不同的结果。

Is the list of device definitions accessible through the command line? 是否可以通过命令行访问设备定义列表? If so, how can I build a device based on one through the command line? 如果是这样,我如何通过命令行构建基于一个设备的设备?

Update: 更新:

When you create a device through the avd gui it creates a config file located at /.android/name-of-your-phone/Config.ini You can add the setup options you want to a new device with -prop example: -prop hw.sdCard=yes -prop sdcard.size=200M , I ran the full command with the -verbose flag and you can see the config it spins up with. 当您通过AVD GUI创建一个设备它创建位于配置文件在/.android/name-of-your-phone/Config.ini您可以添加你要使用新的设备的设置选项-prop例如: -prop hw.sdCard=yes -prop sdcard.size=200M ,我使用-verbose标志运行完整命令,你可以看到它旋转的配置。 It's annoying that the options aren't comma-delineated but whatever. 令人讨厌的是,这些选项不是用逗号描述的,而是用于描述。

The full command that wound up working for me was: 为我工作的完整命令是:

$ANDROID_HOME/tools/emulator -avd phone -gpu on -memory 3072 -prop hw.sdCard=yes -prop sdcard.size=200M -prop disk.dataPartition.size=200M

The ones you're seeing (presumably in Android Studio) are pre-packaged with the IDE. 您正在看到的(可能是在Android Studio中)已预先与IDE一起打包。 If you look in to Android Studio's application files (in Mac) by right clicking on the app file and selecting "Show Package Contents": 如果您通过右键单击应用程序文件并选择“显示包内容”来查看Android Studio的应用程序文件(在Mac中):

Applications ▸ Android Studio.app ▸ Contents ▸ plugins ▸ android ▸ lib ▸ device-art-resources ▸ device-art.xml 应用▸AndroidStudio.app▸内容▸插件▸android▸lib▸器件艺术资源▸device-art.xml

You'll see something like this: 你会看到这样的事情:

...
<device id="galaxy_nexus" name="Galaxy Nexus">
    <orientation name="port" size="1101,1709" screenPos="192,213" screenSize="720,1280" shadow="port_shadow.png" back="port_back.png" lights="port_fore.png"/>
    <orientation name="land" size="1847,886" screenPos="304,68" screenSize="1280,720" shadow="land_shadow.png" back="land_back.png" lights="land_fore.png"/>
</device>
<device id="nexus_s" name="Nexus S">
    <orientation name="port" size="719,1139" screenPos="119,160" screenSize="480,800" shadow="port_shadow.png" back="port_back.png" lights="port_fore.png"/>
    <orientation name="land" size="1210,586" screenPos="208,44" screenSize="800,480" shadow="land_shadow.png" back="land_back.png" lights="land_fore.png"/>
</device>
...

Furthermore, I've found ConfigGenerator.java class in the SDK folder which has all of these pre-packaged device configuration and definitions in Java. 此外,我在SDK文件夹中找到了ConfigGenerator.java类,它具有Java中所有这些预先打包的设备配置和定义。 Take a look, I think this is what you may be looking for. 看一看,我认为这正是您可能正在寻找的。

android-sdks ▸ sources ▸ android-21 ▸ com ▸ android ▸ layoutlib ▸ bridge ▸ intensive ▸ setup ▸ ConfigGenerator.java android-sdks▸信息来源▸android-21▸com▸andor▸布局⑶▸桥▸密集▸设置ConfigGenerator.java

So that being said, you may not have a direct access to use this proprietary avd definitions. 所以说,你可能没有直接访问权限使用这个专有的avd定义。 But perhaps, you could create a script and use this file as a baseline to build on top and derive at your own solution. 但也许,您可以创建一个脚本并使用此文件作为基线来构建在顶层并从您自己的解决方案派生。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM