2012-10-11 15 views
14

Voglio creare emulatore nella riga di comando con alcune opzioni, come hw.mainKeys = false. Ho bisogno che sia uno script di shell in modo che possa essere eseguito sul test di automazione, tuttavia here non sono riuscito a trovare un posto dove impostare tali valori.come creare un emulatore android nella riga di comando con le opzioni?

android create avd 

non dispone di un posto per specificare tali opzioni.

Un'alternativa è creare una 'piattaforma' di tipo avd, tuttavia, la shell è una shell interattiva che è grande per l'uomo, ma difficile per lo script

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>]: 

Esistono alcuni strumenti posso solo passare le opzioni come parametri , come --hw.mainKeys false?

risposta

8

È possibile creare config.ini file di testo con i parametri desiderati

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/ 

consultare la documentazione ufficiale here

+1

come posso usare il config.ini più tardi? –

+1

capito. può essere copiato in name.avd/folder. Grazie –

+4

A partire da agosto 2016 lo "strumento Android" non è più supportato, come afferma una nota sulla pagina della documentazione https://developer.android.com/studio/tools/help/android.html. Questo, da un lato, spiega perché non riesco ancora a farlo funzionare correttamente in Travis CI, dove uso "android create avd" da una riga di comando e, d'altra parte, rende questa risposta obsoleta - sembra che abbiamo bisogno di cercare un nuovo modo per creare l'emulatore da una riga di comando ... – yvolk

2

Date un'occhiata a here

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

Non mi sto chiedendo di nome, destinazione, skin. ma altre opzioni –

+0

Questo è il comando Android deprecato, fyi. – AnneTheAgile

0

basta usare echo no | android create avd -n name -t 9

+0

non funzionano per me (Ubuntu 14.04, strumenti 25.1.7) –

+2

Per quanto riguarda la risposta, l'OP deve prima eseguire "obiettivi elenco Android" e selezionare l'obiettivo pertinente, potrebbe non avere il numero obiettivo 9. –

3

Da 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

Il comando non deprecato ha meno opzioni a riga di comando, ma sono:

$ $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. 
Problemi correlati