RSS

Getting an Android SD Card Image to work on Mac OS X

20 Nov

By Tetchro

hen I began experimenting with Android development one of the first hurdles I encountered was trying to get the emulator to recognize a fake sd card so that I could reference it in the emulator. There doesn’t seem to be a whole lot of resources out there for doing this on Mac OS X (at least that I could find, but usually I can’t find anything on the internet so what do I know?), so after finally figuring it out with the help of a few different websites, I thought I’d post it here for any one else struggling and also for my own reference in case I ever need to do it again! I’ll keep the steps as simple as possible after the initial step (getting Eclipse installed and all that jazz). Basically, we just want to create an .iso file and get Eclipse to recognize that it exists:

  1. Obviously, install Eclipse, the SDK, and the ADT plugin package on your Mac… here’s a link to instructions on how to do this. It should be pretty straightforward, although I found the Android Developer’s website a little confusing to navigate.
    http://developer.android.com/sdk/installing.html
  2. Once you run Eclipse and get everything set up, you should have a workspace (by default I believe it ends up in your Documents folder. So in my case, since my username is Riley, the /Users/Riley/Documents/workspace directory). We’ll use this to store our sd card (you don’t have to though… you can put it anywhere you’d like! My examples that follow use this directory)
  3. Open up Terminal (it’s in Applications -> Utilities -> Terminal for those of you who have lived sheltered lives!)
  4. The first thing you want to do it navigate to the “tools” folder inside the sdk folder you downloaded from the Android developers website. In my case, the folder is called “android-sdk-macosx” (I saw some examples with different names, so I just wanted to be clear here) and it’s located on my desktop. So in my case, I would write into terminal:
    cd /Users/Riley/Desktop/android-sdk-macosx/tools

    So, basically,

    cd [directory of sdk tools folder]

    That should be simple enough if you know where you put the folder!

  5. Next, you want to create an .iso file in your workspace directory. In my case, I wanted a 1gb (1024 mb) “fake” sdcard to play with, so I typed into Terminal:
    ./mksdcard 1024M /Users/Riley/Documents/workspace/sdcard1.iso

    This runs an application called mksdcard in the tools folder we navigated to before and creates a 1024 mb .iso file in the directory /Users/Riley/Documents/workspace/sdcard1.iso. I named my sdcard “sdcard1.iso,” but you can give it a different name, of course. The basic command of this structure is:

    ./mksdcard [size] [name and location of file to be created]

    Both of the terminal commands. Now the sdcard1.iso exists!

    If you just type “./mksdcard 1024M sdcard1.iso” it will create “sdcard1.iso” in the tools folder in the sdk.Here’s a link to some more information about mksdcard from the Android Developer website. The minimum size of the sdcard image is 9 mb, and the maximum size is 1023 gb (pretty generous!).

  6. Next, find your “sdcard1.iso” (or whatever you named it) file and double-click it. This will mount the image under “devices,” which can be found in finder under the name “SDCARD”. To stick some stuff on it (in the picture I put a few audio files on there. Android, when you first run the emulator from Eclipse, creates the “Android” and “LOST.DIR” folders automatically) just drag and drop as you would with a normal USB drive. 

    The newly created sdcard1.iso can be found in Finder under “Devices” with the name SDCARD.

  7. Fire up Eclipse and navigate to the project you want to use the sdcard in.
  8. Go to Run -> Debug Configurations
  9. Click the “Target” tab on the right side of the window that pops up, and find the “Additional Emulator Command Line Options” textbox. When you first open this window, YOU MAY NEED TO SCROLL DOWN IN THE FRAME TO SEE THIS BOX. To make life easier for yourself, you can also simply expand the “Debug Configurations” window, and the textbox at the bottom should appear. I mention this because I was an idiot and didn’t realize I had to scroll down at first and thought I was in the wrong place. :P
  10. Type in “-sdcard [directory of sdcard1.iso]” (without the quotes, as seen in the image below). In my case, I wrote:
    -sdcard /Users/Riley/Documents/workspace/sdcard1.iso
  11. Click “Apply”. This also updates the “Run Configurations” settings (also available under the “Run” menu), so you don’t need to alter those. 

    Debug configurations altered to include the sdcard1.iso image.

  12. You should now be able to access the (fake) sdcard by using the directory /sdcard/
    As for where you go now, that’s up to you!

I can try to answer any questions if you run into problems, but hopefully this offers some help for any one that was confused about this whole process. Good luck!

 

Copy from: http://www.lagserv.net/wp/2012/04/tutorial-getting-an-android-sd-card-image-to-work-on-mac-os-x/

Advertisements
 
Leave a comment

Posted by on November 20, 2012 in Android, Mac

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: