20

I want to create emulator in command line with some options, like hw.mainKeys = false. I need it to be an shell script so can run on automation test,however here I could not find a place to set those values.

android create avd 

do not have a place to specify those options.

One alternative is create a 'platform' type avd, however, the shell is a interactive shell that is great for human but hard for 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>]:

Are there some tools I can just pass options as parameters, like --hw.mainKeys false ?

5 Answers 5

10

You can create text file config.ini with desired parameters

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/

See official documentation here

Sign up to request clarification or add additional context in comments.

7 Comments

how can I use the config.ini later?
got it. it can be copied to name.avd/ folder. Thanks
As of August 2016 the "android tool" is no longer supported, as states a note on the documentation page developer.android.com/studio/tools/help/android.html. This, on one hand, explains, why I still cannot get it working properly in Travis CI , where I use "android create avd" from a command line, and on the other hand, makes this answer outdated - it looks like we need to seach for some new way to create emulator from a command line...
@david.schreiber Since my previous comment I managed to minimize usage of the "android tool"'s command line parameters by providing most of configuration parameters via config.ini file, created by Android Studio. See github.com/andstatus/andstatus/blob/master/.travis.yml
Thanks for coming back @yvolk! I'm now using similar approach with preloading different AVD config files (for my use case) which works very well 👌
|
6

The non-deprecated command has fewer commandline options, but they are:

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

Comments

5

From 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)

Comments

2

Take a look at here

android create avd -n Ev o4G -t 9 -c 8000M -s 480-800

1 Comment

I am not asking about name, target, skin. but other options
0

just use echo no | android create avd -n name -t 9

1 Comment

In regard to your answer, the OP should first run "android list targets" and select the relevant target, he may not have target number 9.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.