Thunderbeef Thunderbeef - 3 years ago 341
Android Question

Android emulator does not mount external SD card

I'm trying to run freshly built Android image on emulator (generic

target built from current
using Google sources). The emulator seems to be working fine, except it does not mount external SD card when run with
option. Emulator version is the one that comes from the git. Everything is executed on a headless server.

My complete list of steps:

repo init -u
repo sync
. build/
lunch aosp_x86-eng
make -j16
mksdcard 1G sd.img
emulator -no-window -no-skin -no-audio -sdcard sd.img &
adb shell mount | grep vfat

The virtual device appears to be correctly forwarded, as seen by the output of
adb shell blkid

/dev/block/vda1: LABEL="system" UUID="da594c53-9beb-f85c-85c5-cedf76546f7a" TYPE="ext4"
/dev/block/vdb: LABEL="cache" UUID="f73de97f-7017-ca5e-9b47-ca9c8f633e83" TYPE="ext4"
/dev/block/vde1: LABEL="vendor" UUID="6d16bab1-58d9-3c5d-8f14-f608f924affd" TYPE="ext4"
/dev/block/vdf: LABEL="SDCARD" UUID="1CEA-0B06" TYPE="vfat"

However, it is not mounted by
. What could be the problem?

I also get the same result when I run emulator using Android 8 image downloaded via SDK manager. With Android 7, SD card works OK.


Solved the issue for emulator that comes with aosp_x86-eng build (see my own answer). On the emulator from Android SDK, the cause is probably different.

Answer Source

Turns out, in my case headless mode was the culprit. When I run emulator with -no-skin -no-window options, SD card is not mounted. If I remove these options (and enable X11 forwarding, since I work on a headless server), everything works correctly.

I still want to know why I can't use SD card in headless mode, but at least I was able to solve the problem for the required task.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download