13

I want to edit or change the ram size while creating the android emulator from command line.

EX: While creating the emulator it's taking default ram size(Android SDK 4.0.3) 512 MB But I want to increase it to 768MB or decrease it to 256MB.

I want to change only Ram size. Because there is an option to change the Ram size.

 Do you wish to create a custom hardware profile [no] Yes

If you entered yes, we need to provide so many things.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Srikanth Chilukuri
  • 563
  • 4
  • 17
  • 31

3 Answers3

20

You need to find the config file for the AVD that you have created.

In my case, I'm running the AVD on Ubuntu, so this is where I found the config file.

~/.android/avd/emulator.avd/config.ini

"emulator" was the name I provided when I created the AVD, so the directory name will depend on what you provided.

The following is what is inside the config.ini file:

hw.lcd.density=240
skin.name=WVGA800
skin.path=platforms/android-8/skins/WVGA800
hw.cpu.arch=arm
abi.type=armeabi
vm.heapSize=64
hw.ramSize=1024
image.sysdir.1=platforms/android-8/images/

I increased my heap size from 24 to 64, and added the ram size parameter.

For the list of parameters you can add, refer to: Managing AVDs from the Command-line

Chan Tzish
  • 1,108
  • 9
  • 7
Shane Oliver
  • 944
  • 1
  • 8
  • 17
  • the new working link is http://www.androiddocs.com/tools/devices/managing-avds-cmdline.html but several parameters are not listed: vm.heapSize, disk.dataPartition.size, hw.lcd.height, hw.lcd.width... – baptx Dec 03 '18 at 11:29
12

To answer the question in the title,

how to change the android emulator ram size from command line?

one has to use -memory option:

emulator -memory 768 -avd <AVD_NAME>

or

emulator -memory 256 -avd <AVD_NAME>
ozbek
  • 20,955
  • 5
  • 61
  • 84
  • 2
    Reference document for emulator flag options: https://developer.android.com/studio/run/emulator-commandline#startup-options – Mr-IDE Oct 25 '18 at 21:11
  • And that's not changing configuration, but just launching emulator with specified amount of memory. `config.ini` still remains the same. – eleven Jan 31 '19 at 15:32
  • @eleven: well, if we are going that technical, then `-memory` option does indeed change the emulator RAM size. It just does not persist the change (or save it to config file). – ozbek Feb 07 '19 at 06:40
2

You can change the default value of hw.ramSize in hardware.ini which you uses. For example, if you change the platforms/android-15/skins/**WVGA800**/hardware.ini to

hw.lcd.density=240
vm.heapSize=48
hw.ramSize=1024

Then you can create an avd that has 1024M of ram by using:

android create avd -f -t <target> -s **WVGA800** -n test_avd
moribvndvs
  • 42,191
  • 11
  • 135
  • 149
yu_chun
  • 21
  • 2
  • Using WVGA800 did not work for me — but then I create an API 10 compatibility tests emulator. – Martin Feb 27 '14 at 13:08