How do I resize internal storage of an Android Studio AVD image that’s stuck at 200MB?

When I try to resize the internal storage partition size in AVD (Android Virtual Device) manager to anything larger than 200MB, the darn thing stays at 200MB. This mounts to /data directory. The problem rears it’s head with Android API 19 / KitKat 4.4.x images and possibly others.

Best Answer

This is a known problem. I imagine that nobody has made the investment to fix because it affects an earlier API version/build. But, if you’re on a Mac, here’s your fix.

  1. Go into AVD and set the Internal Storage size to 1GB (or whatever size you need — I’ve only tested this to 1GB).
  2. Run the image to make sure that it boots up okay. (this is just to rule out any other problem that might be ailing your image) If you look at the image partitions, it should still be only 200MB.
  3. Stop the image from running.
  4. From the command line, run: gtruncate --size 1g userdata.img. If you don’t have gtruncate, install it with brew install coreutils.
  5. From the command line, run: tune2fs -e continue userdata.img. If you don’t have tune2fs, install it with brew install e2fsprogs. If you still can’t find it after installing, check /usr/local/Cellar/e2fsprogs/{whateverversion}/sbin/tune2fs.
  6. If you also have a userdata-qemu.img file, you can repeat steps 4 and 5 for that image file. If you get an error, best bet is just to delete userdata-qemu.img and let AVD automatically recreate it.
  7. Run the image. Verify that your partition is 1GB. Celebrate.

You may Also Like:

Leave a Comment