Android

Other Tools

The sections below describe other tools that you can use when building Android applications.

All of the tools are included in the Android SDK and are accessible from the tools/ directory.

Contents

mksdcard
dx
activitycreator

mksdcard

The mksdcard tool lets you quickly create a FAT32 disk image that you can load in the emulator, to simulate the presence of an SD card in the device. Here is the usage for mksdcard:

mksdcard [-l label] <size>[K|M] <file>

The table below lists the available options/arguments

Argument Description
-l A volume label for the disk image to create.
size An integer that specifies the size (in bytes) of disk image to create. You can also specify size in kilobytes or megabytes, by appending a "K" or "M" to <size>. For example, 1048576K, 1024M.
file The path/filename of the disk image to create.

Once you have created the disk image file, you can load it in the emulator at startup using the emulator's -sdcard option. For more information, see Android Emulator.

emulator -sdcard <file>

dx

The dx tool lets you generate Android bytecode from .class files. The tool converts target files and/or directories to Dalvik executable format (.dex) files, so that they can run in the Android environment. It can also dump the class files in a human-readable format and run a target unit test. You can get the usage and options for this tool by using dx -help.

activitycreator

If you aren't using the Eclipse IDE and ADT plugin, you can use the the activitycreator script to get started with a new application. When you run the script, it creates the structure of a minimal Android application that you can build on and extend to meet your needs.

For Linux and Mac, the SDK provides activitycreator.py, a Python script, and for Windows activitycreator.bat, a batch script that runs an executable. Regardless of platform, the usage for the script is the same:

activitycreator [--out <folder>] [--ide intellij] your.package.name.ActivityName
Option Description
--out <folder> Specifies where to create the files/folders.
--ide intellij Creates project files for IntelliJ

When run, the script creates these files:

  • AndroidManifest.xml -- The application manifest file.
  • build.xml -- An Ant script to build/package the application.
  • res -- The resource directory.
  • src -- The source directory.
  • src/your/package/name/ActivityName.java -- The Activity class.
  • bin -- The output folder for the compiled .apk (when built by Ant).

When you are ready, you can use Ant to build the project so that you can run it on the emulator.

If you are using Eclipse with the ADT plugin, you do not need to use activitycreator. You can use the New Project Wizard, provided by the ADT plugin, instead.

Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56