How to change the android emulator RAM size from t

2020-01-31 07:41发布

问题:

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.

回答1:

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



回答2:

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>


回答3:

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