タイトルそのままなんだけど、私の環境で発生して解決できたようなのでメモ。
AVDを使わずに、フルソースをビルドして出来上がった各種イメージファイル(out/target/product/generic/system.imgなど)を使ってエミュレータを起動した場合(emulatorのパラメータで-system/-ramdisk/-kernelなどを付けたとき)、-sdcardでSDイメージファイルをちゃんと指定していてもエミュレータがSDイメージを認識せずに「SDが刺さっていない」ことになってしまうことがあるようだ。
mksdcardでイメージを作り直したりしても同じで、しばらくハマっていたところで本家フォーラムで回避策を発見。
Cupcake Emulator do not mount SD card image - Android Developers | Google グループ
実際のバグトラッキングページはこちら↓。
Change 9452: Ensure that /system/etc/vold.conf is created in the "generic" product. This is necessary to let the emulator mount SD Card images properly through the "vold" mounting daemon | review.source Code Review
どうもソースをmakeしたときに、out/target/product/generic/system/etc/ の下にvold.confというファイルが作成されないかららしい。
ちなみにvold.confの中身はというと、
## vold configuration file for the emulator/SDK
volume_sdcard {
## This is the direct uevent device path to the SD slot on the device
emu_media_path /devices/platform/goldfish_mmc.0/mmc_host/mmc0
media_type mmc
mount_point /sdcard
ums_path /devices/platform/usb_mass_storage/lun0
}
と、SDのマウントの設定が書かれている。これが無いとそもそもエミュレータがSDを認識しないようになってる模様。
さてvold.confが正しく生成されるために、ここにある差分をマージする。
diff --git a/core/main.mk b/core/main.mk
--- a/core/main.mk
+++ b/core/main.mk
@@ -209,6 +209,14 @@ ifeq (,$(filter %:system/etc/apns-conf.xml, $(PRODUCT_COPY_FILES)))
$(warning implicitly installing apns-conf_sdk.xml)
endif
endif
+# Install a vold.conf file is one's not already being installed.
+ifeq (,$(filter %:system/etc/vold.conf, $(PRODUCT_COPY_FILES)))
+ PRODUCT_COPY_FILES += \
+ development/data/etc/vold.conf:system/etc/vold.conf
+ ifeq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
+ $(warning implicitly installing vold.conf)
+ endif
+endif
# If we're on an eng or tests build, but not on the sdk, and we have
# a better one, use that instead.
ifneq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
パッチ適用後もう一度makeすると、vold.confが生成される。またsystem.imgも更新されるようだ。
これでエミュレータを起動すると、今度はきちんとSDが認識されるようになる。
...これで半日くらい潰した...。