Mounting a SD Card in the Android Emulator

Unlike the backberry emulator the android emulator doesnt simply pretend that a directory on your drive is the SD card. You need a formatted .img file that it will use as the SD Card.
Why do you need the SD Card? Well besides using the SD Card in your app, the more important use is for profiling and debugging. Without the SD Card you will hit errors like
Unable to open trace file permission denied
Here are the steps to setup the card.:
  1. Open up the console (cmd) and navigate to the android SDK tools folder cd Android\android-sdk-windows\tools\
  2. Create your SD Card image. NOTE: 8MB is the minimum size the emulator will accept mksdcard -l mySdCard 1024M mySdCardFile.img
  3. Open up Eclipse and modify your run configuration. In the 'Target' tab enter th following for 'Additional Emulator Command Line Options': -sdcard C:\Android\android-sdk-windows\SDCard\SDCard64MB.img
  4. Click run and you should have an emulator with an SD Card.
If you are faced with: ERROR: the user data image is used by another emulator. aborting, or if the SD Card doesn't show, try restarting adb.

To restart adb enter the following in the command prompt: cd C:\android-sdk-windows\platform-tools adb kill-server adb start-server

0 comments: