Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create android emulator in command line with options?

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 ?

like image 956
cheng yang Avatar asked Oct 11 '12 18:10

cheng yang


People also ask

How do I run an emulator from command prompt?

Starting the emulator Use the emulator command to start the emulator, as an alternative to running your project or starting it through the AVD Manager. Here's the basic command-line syntax for starting a virtual device from a terminal prompt: emulator -avd avd_name [ {- option [ value ]} … ]

How do you code an Android Emulator?

To create an Android emulator on your system, follow these steps: Start the Android SDK Manager (select Start | All Programs | Embarcadero RAD Studio | Android Tools). In the Android SDK Manager, select Tools | Manage AVDs. In the Android Virtual Device Manager, click the New button to create a new virtual device.

How do I update my emulator from command line?

You have two ways going forward to update the emulator: Use the new command line SDK Manager: $ ./sdkmanager --update Read more here. Use the new SDK Manager in Android Studio.


2 Answers

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

like image 196
vasart Avatar answered Oct 03 '22 08:10

vasart


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)
like image 28
Jianxin Gao Avatar answered Oct 03 '22 09:10

Jianxin Gao