Android SDK - Guide

Download the Android SDK

Welcome Developers! If you are new to the Android SDK, please read the steps below, for an overview of how to set up the SDK.
If you're already using the Android SDK, you should update to the latest tools or platform using the Android SDK and AVD Manager, rather than downloading a new SDK starter package. See Adding SDK Components.
Platform Package Size MD5 Checksum
Windows android-sdk_r18-windows.zip 37448775 bytes bfbfdf8b2d0fdecc2a621544d706fa98
installer_r18-windows.exe (Recommended) 37456234 bytes 48b1fe7b431afe6b9c8a992bf75dd898
Mac OS X (intel) android-sdk_r18-macosx.zip 33903758 bytes 8328e8a5531c9d6f6f1a0261cb97af36
Linux (i386) android-sdk_r18-linux.tgz 29731463 bytes 6cd716d0e04624b865ffed3c25b3485c
Here's an overview of the steps you must follow to set up the Android SDK:
  1. Prepare your development computer and ensure it meets the system requirements.
  2. Install the SDK starter package from the table above. (If you're on Windows, download the installer for help with the initial setup.)
  3. Install the ADT Plugin for Eclipse (if you'll be developing in Eclipse).
  4. Add Android platforms and other packages to your SDK.
  5. Explore the contents of the Android SDK (optional).
To get started, download the appropriate package from the table above, then read the guide to Installing the SDK.

Adding SDK Packages

Quickview

  • Use the Android SDK Manager to set up your SDK and keep it up-to-date.

In this document

  1. Launching the Android SDK Manager
  2. Installing SDK Packages
  3. Updating SDK Packages
  4. Package Dependencies
  5. Adding New Sites
  6. Troubleshooting
Adding and updating packages in your Android SDK is fast and easy. To add or update the individual SDK packages that you need, use the Android SDK Manager (included in the SDK Tools).
It only takes a couple of clicks to install individual versions of the Android platform, new development tools, new documentation, and SDK add-ons. The new SDK packages are automatically installed into your existing SDK directory, so you don't need to update your development environment to specify a new SDK location.
If you're setting up your Android SDK for the first time, see Installing the SDK for information about what packages to install.
Note: If you develop in Eclipse, you might also need to update your ADT plugin when you update your development tools. See the revisions listed in the ADT Plugin for Eclipse document.

Figure 1. The Android SDK Manager's Available Packages panel, which shows the SDK packages that are available for you to download into your environment.

Launching the Android SDK Manager

The Android SDK Manager is the tool that you use to install and upgrade SDK packages in your development environment.
You can launch the Android SDK Manager in one of the following ways.

Launching from Eclipse/ADT

If you are developing in Eclipse and have already installed the ADT Plugin, follow these steps to access the Android SDK Manager tool:
  1. Open Eclipse
  2. Select Window > Android SDK Manager.

Launching from the SDK Manager script (Windows only)

For Windows only, the SDK includes a script that invokes the Android SDK Manager. To launch the tool using the script, double-click SDK Manager.exe at the root of the the SDK directory.

Launching from a command line

In all development environments, follow these steps to access the Android SDK Manager tool from the command line:
  1. Navigate to the <sdk>/tools/ directory.
  2. Execute the android tool command with no options.
    $ android

Installing SDK Packages

Caution: Before you install SDK packages, we recommend that you disable any antivirus software that may be running on your computer. There are cases in which antivirus software on Windows is known to interfere with the installation process, so we suggest you disable your antivirus until installation is complete.
Follow these steps to install new SDK packages in your environment:
  1. Launch the Android SDK Manager as described in the section above.
  2. Select Available Packages in the left panel. This will reveal all of the packages that are currently available for download from the SDK repository.
  3. Select the package(s) you'd like to install and click Install Selected. (If you aren't sure which packages to select, read Recommended Packages.)
  4. Verify and accept the packages you want (ensure each one is selected with a green checkmark) and click Install. The packages will now be installed into your existing Android SDK directories.
New platforms are automatically saved into the /platforms/ directory of your SDK; new add-ons are saved in the /add-ons/ directory; samples are saved in the /samples/android-/; and new documentation is saved in the existing /docs/ directory (old docs are replaced).

Updating SDK Packages

From time to time, new revisions of existing SDK packages are released and made available to you through the SDK repository. In most cases, if you have those packages installed in your environment, you will want to download the new revisions as soon as possible.
You can learn about the release of new revisions in two ways:
  • You can watch for updates listed in the "SDK" tab of the Android Developers site, in the "Downloadable SDK Packages" section.
  • You can watch for updates listed in the Available Packages panel of the Android SDK Manager.
When you see that a new revision is available, you can use the Android SDK Manager to quickly download it to your environment. Follow the same procedure as given in Installing SDK Packages, above. The new package is installed in place of the old, but without impacting your applications.
Tip: Use the "Display updates only" checkbox to show only the packages you do not have.

SDK Package Dependencies

In some cases, an SDK package may require a specific minimum revision of another package or SDK tool. Where such dependencies exist, they are documented in the revision notes for each package, available from the links in the "Downloadable SDK packages" section at left.
For example, there may be a dependency between the ADT Plugin for Eclipse and the SDK Tools package. When you install the SDK Tools package, you should also upgrade to the required version of ADT (if you are developing in Eclipse). In this case, the major version number for your ADT plugin should always match the revision number of your SDK Tools (for example, ADT 8.x requires SDK Tools r8).
Also make sure that, each time you install a new version of the Android platform, you have the latest version of the SDK Platform-tools package. The SDK Platform-tools contain tools that are backward compatible with all versions of the Android platform and are often updated to support new features in the latest version of the Android platform.
The development tools will notify you with debug warnings if there is dependency that you need to address. The Android SDK Manager also enforces dependencies by requiring that you download any packages that are needed by those you have selected.

Adding New Sites

By default, Available Packages displays packages available from the Android Repository and Third party Add-ons. You can add other sites that host their own Android SDK add-ons, then download the SDK add-ons from those sites.
For example, a mobile carrier or device manufacturer might offer additional API libraries that are supported by their own Android-powered devices. In order to develop using their libraries, you must install their Android SDK add-on, if it's not already available under Third party Add-ons.
If a carrier or device manufacturer has hosted an SDK add-on repository file on their web site, follow these steps to add their site to the Android SDK Manager:
  1. Select Available Packages in the left panel.
  2. Click Add Add-on Site and enter the URL of the repository.xml file. Click OK.
Any SDK packages available from the site will now be listed under a new item named User Add-ons.

Troubleshooting

Problems connecting to the SDK repository
If you are using the Android SDK Manager to download packages and are encountering connection problems, try connecting over http, rather than https. To switch the protocol used by the Android SDK Manager, follow these steps:
  1. With the Android SDK Manager window open, select "Settings" in the left pane.
  2. On the right, in the "Misc" section, check the checkbox labeled "Force https://... sources to be fetched using http://..."
  3. Click Save & Apply.

Managing Virtual Devices

An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.
The easiest way to create an AVD is to use the graphical AVD Manager, which you launch from Eclipse by clicking Window > AVD Manager. You can also start the AVD Manager from the command line by calling the android tool with the avd options, from the /tools/ directory.
You can also create AVDs on the command line by passing the android tool options. For more information on how to create AVDs in this manner, see Managing Virtual Devices from the Command Line.
An AVD consists of:
  • A hardware profile: Defines the hardware features of the virtual device. For example, you can define whether the device has a camera, whether it uses a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on.
  • A mapping to a system image: You can define what version of the Android platform will run on the virtual device. You can choose a version of the standard Android platform or the system image packaged with an SDK add-on.
  • Other options: You can specify the emulator skin you want to use with the AVD, which lets you control the screen dimensions, appearance, and so on. You can also specify the emulated SD card to use with the AVD.
  • A dedicated storage area on your development machine: the device's user data (installed applications, settings, and so on) and emulated SD card are stored in this area.
You can create as many AVDs as you need, based on the types of device you want to model. To thoroughly test your application, you should create an AVD for each general device configuration (for example, different screen sizes and platform versions) with which your application is compatible and test your application on each one.
Keep these points in mind when you are selecting a system image target for your AVD:
  • The API Level of the target is important, because your application will not be able to run on a system image whose API Level is less than that required by your application, as specified in the minSdkVersion attribute of the application's manifest file. For more information about the relationship between system API Level and application minSdkVersion, see Specifying Minimum System API Version.
  • You should create at least one AVD that uses a target whose API Level is greater than that required by your application, because it allows you to test the forward-compatibility of your application. Forward-compatibility testing ensures that, when users who have downloaded your application receive a system update, your application will continue to function normally.
  • If your application declares a uses-library element in its manifest file, the application can only run on a system image in which that external library is present. If you want to run your application on an emulator, create an AVD that includes the required library. Usually, you must create such an AVD using an Add-on component for the AVD's platform (for example, the Google APIs Add-on contains the Google Maps library).
To learn how to manage AVDs using a graphical tool, read Managing AVDs with AVD Manager. To learn how to manage AVDs on the command line, read Managing AVDs from the Command Line.

http://developer.android.com/guide/developing/devices/index.html

Managing AVDs with AVD Manager

The AVD Manager is an easy to use user interface to manage your AVD (Android Virtual Device) configurations. An AVD is a device configuration for the Android emulator that allows you to model different configurations of Android-powered devices. When you start the AVD Manager in Eclipse or run the android tool on the command line, you will see the AVD Manager as shown in figure 1:
Figure 1. Screenshot of the AVD Manager.
From the main screen, you can create, delete, repair and start AVDs as well as see the details of each AVD.

Creating an AVD

You can create as many AVDs as you would like to test on. It is recommended that you test your applications on all API levels higher than the target API level for your application.
To create an AVD:
  1. Start the AVD Manager:
    • In Eclipse: select Window > AVD Manager, or click the AVD Manager icon in the Eclipse toolbar.
    • In other IDEs: Navigate to your SDK's tools/ directory and execute the android tool with no arguments.
  2. In the Virtual Devices panel, you'll see a list of existing AVDs. Click New to create a new AVD. The Create New AVD dialog appears.
    AVD Dialog
    Figure 2. Screenshot of the Create AVD window
  3. Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a skin (HVGA is default). You can also add specific hardware features of the emulated device by clicking the New... button and selecting the feature. For a list of hardware features, see Hardware options.
    Note: Be sure to define a target for your AVD that satisfies your application's Build Target (the AVD platform target must have an API Level equal to or greater than the API Level that your application compiles against).
  4. Click Create AVD.
Your AVD is now ready and you can either close the AVD Manager, create more AVDs, or launch an emulator with the AVD by selecting a device and clicking Start.

Hardware options

If you are creating a new AVD, you can specify the following hardware options for the AVD to emulate:
Characteristic Description Property
Device ram size The amount of physical RAM on the device, in megabytes. Default value is "96". hw.ramSize
Touch-screen support Whether there is a touch screen or not on the device. Default value is "yes". hw.touchScreen
Trackball support Whether there is a trackball on the device. Default value is "yes". hw.trackBall
Keyboard support Whether the device has a QWERTY keyboard. Default value is "yes". hw.keyboard
DPad support Whether the device has DPad keys. Default value is "yes". hw.dPad
GSM modem support Whether there is a GSM modem in the device. Default value is "yes". hw.gsmModem
Camera support Whether the device has a camera. Default value is "no". hw.camera
Maximum horizontal camera pixels Default value is "640". hw.camera.maxHorizontalPixels
Maximum vertical camera pixels Default value is "480". hw.camera.maxVerticalPixels
GPS support Whether there is a GPS in the device. Default value is "yes". hw.gps
Battery support Whether the device can run on a battery. Default value is "yes". hw.battery
Accelerometer Whether there is an accelerometer in the device. Default value is "yes". hw.accelerometer
Audio recording support Whether the device can record audio. Default value is "yes". hw.audioInput
Audio playback support Whether the device can play audio. Default value is "yes". hw.audioOutput
SD Card support Whether the device supports insertion/removal of virtual SD Cards. Default value is "yes". hw.sdCard
Cache partition support Whether we use a /cache partition on the device. Default value is "yes". disk.cachePartition
Cache partition size Default value is "66MB". disk.cachePartition.size
Abstracted LCD density Sets the generalized density characteristic used by the AVD's screen. Default value is "160". hw.lcd.density
http://developer.android.com/guide/developing/devices/managing-avds.html

0 comments: