How to set emulator pixel density from the command line?

(Using android sdk 25.1.6)

I create and open the Android emulator from the command line:

$> android create avd -n my_device -t 9 --skin 1440x2560 --abi default/x86 

How to set pixel density?

I tried the following approaches:

  • After executing the above command, I will answer yes to the creation of the equipment profile. When they ask me what density to use, I type 570, but he does not accept it (he again asks me the same question) and accepts only empty input (by default).

  • After creating the emulator, open the file ~ / .android / avd / my_avd.ini and add:

     hw.lcd.density=570 

    but this parameter is ignored.

  • add this flag when opening the emulator:

     $> emulator avd my_avd -dpi-device 570 

    but I get:

     WARNING: The -dpi-device flag is obsolete and will be ignored 

Any idea?

+10
android android-emulator avd android-avd
source share
2 answers

Your second approach works, but you used an invalid DPI number.

After creating the emulator, open ~ / .android / avd / my_avd / config.ini and add:
hw.lcd.density=560

You can only select the following DPIs:
120, 160, 213, 240, 280, 320, 360, 400, 420, 480, 560, 640

0
source share

Use flag -skin 768x1280

 Android/Sdk/tools/emulator -avd android2 -skin 768x1280 -use-system-libs 
-3
source share

All Articles