2012-10-11 21 views
14

我想用一些選項在命令行中創建模擬器,如hw.mainKeys = false。 我需要它是一個shell腳本,所以可以在自動化測試上運行,但是here我無法找到設置這些值的地方。如何在命令行中使用選項創建android模擬器?

android create avd 

沒有地方指定這些選項。

一種替代方法是創建一個「平臺」型的AVD,然而,外殼是一個交互的shell是偉大的人,但很難腳本

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

Name of the AVD being run: 
avd.name [<build>]: 

是否有一些工具,我可以通過選項參數,像--hw.mainKeys false

回答

8

您可以創建文本文件的config.ini與所需的參數

hw.lcd.density=252 
sdcard.size=32M 
skin.name=NEXUS-ONE 
skin.path=platforms/android-10/skins/NEXUS-ONE 
hw.cpu.arch=arm 
hw.keyboard.lid=no 
abi.type=armeabi 
hw.keyboard=no 
vm.heapSize=24 
hw.ramSize=256 
image.sysdir.1=platforms/android-10/images/ 

參見官方文檔here

+1

我怎樣才能在以後使用的config.ini文件? –

+1

明白了。它可以被複制到name.avd /文件夾。謝謝 –

+4

截至2016年8月,不再支持「android工具」,因爲在文檔頁面https://developer.android.com/studio/tools/help/android.html上聲明瞭一個註釋。這一方面解釋了爲什麼我仍然無法在Travis CI中正常工作,我在命令行中使用「android create avd」,另一方面,這個答案已經過時 - 看起來我們需要尋找一些新的方式來從命令行創建模擬器... – yvolk

2

看看here

android create avd -n Ev o4G -t 9 -c 8000MB -s 480-800 
+1

我不問關於名稱,目標,皮膚。但其他選項 –

+0

這是已棄用的android命令fyi。 – AnneTheAgile

0

只使用echo no | android create avd -n name -t 9

+0

不適合我(Ubuntu 14.04,工具25.1.7) –

+2

關於你的回答,OP應該首先運行「android list targets」並選擇相關目標,他可能沒有目標編號9。 –

3

android --help create avd

Usage: 
    android [global options] create avd [action options] 
    Global options: 
    -s --silent  : Silent mode, shows errors only. 
    -v --verbose : Verbose mode, shows errors, warnings and all messages. 
    --clear-cache: Clear the SDK Manager repository manifest cache. 
    -h --help  : Help on a specific command. 

       Action "create avd": 
    Creates a new Android Virtual Device. 
    Options: 
    -t --target : Target ID of the new AVD. [required] 
    -a --snapshot: Place a snapshots file in the AVD, to enable persistence. 
    -c --sdcard : Path to a shared SD card image, or size of a new sdcard for 
      the new AVD. 
    -p --path : Directory where the new AVD will be created. 
    -b --abi  : The ABI to use for the AVD. The default is to auto-select the 
      ABI if the platform has only one ABI for its system images. 
    -d --device : The optional device definition to use. Can be a device index 
      or id. 
    -n --name : Name of the new AVD. [required] 
    -s --skin : Skin for the new AVD. 
    -g --tag  : The sys-img tag to use for the AVD. The default is to 
      auto-select if the platform has only one tag for its system 
      images. 
    -f --force : Forces creation (overwrites an existing AVD) 
1

非過時的命令具有較少的命令行選項,但它們是:

$ $ANDROID_HOME/tools/bin/avdmanager --help create 

Usage: 
     avdmanager [global options] create [action options] 
     Global options: 
    -s --silent  : Silent mode, shows errors only. 
    -v --verbose : Verbose mode, shows errors, warnings and all messages. 
    --clear-cache: Clear the SDK Manager repository manifest cache. 
    -h --help  : Help on a specific command. 

Valid actions are composed of a verb and an optional direct object: 
- create avd   : Creates a new Android Virtual Device. 

Action "create avd": 
    Creates a new Android Virtual Device. 
Options: 
    -a --snapshot: Place a snapshots file in the AVD, to enable persistence. 
    -c --sdcard : Path to a shared SD card image, or size of a new sdcard for 
       the new AVD. 
    -g --tag  : The sys-img tag to use for the AVD. The default is to 
       auto-select if the platform has only one tag for its system 
       images. 
    -p --path : Directory where the new AVD will be created. 
    -k --package : Package path of the system image for this AVD (e.g. 
       'system-images;android-19;google_apis;x86'). [required] 
    -n --name : Name of the new AVD. [required] 
    -f --force : Forces creation (overwrites an existing AVD) 
    -b --abi  : The ABI to use for the AVD. The default is to auto-select the 
       ABI if the platform has only one ABI for its system images. 
    -d --device : The optional device definition to use. Can be a device index 
       or id. 
相關問題