androidandroid-emulatorqemu

How to reduce the size of the Android Studio virtual device folder


I noticed that in the virtual machine folder at this address:

/Users/username/.android/avd/{AVD_Name}.avd/

There are two files named: 1- userdata-qemu.img | 2- userdata-qemu.img.qcow2

The first file is related to the internal memory of the device. And I think the second file is backed up from the first file.

The problem here is that if I have defined the size of my internal memory as two gigs and fill all the space of two gigs of my virtual machine, in fact the size of my folder will be 4 gigs (because of the file userdata-qemu.img.qcow2). Now if I delete those two gigs of internal space, put new content again, the size of the userdata-qemu.img.qcow2 file increases and never decreases, and this continues indefinitely, maybe 100 gigs of space will be allocated to it!

So I want to stop this terrible increase in the size of the 'userdata-qemu.img.qcow2' file of my virtual machine. Is there a solution for this?


Solution

  • So I want to stop this terrible increase in the size of the 'userdata-qemu.img.qcow2' file of my virtual machine. Is there a solution for this?

    It's strange, but it's ok to delete userdata.img and userdata-qemu.img, the real data file is userdata-qemu.img.qcow2. But emulator can't run without the last file, so you need to make an empty one:

    rm userdata.img
    rm userdata-qemu.img
    touch userdata-qemu.img
    

    I've gained 6,5GB + 0,5GB for just one of virtual devices.