page.title=Upgrading the SDK sdk.version=1.6 @jd:body

Upgrading the SDK

In this document

  1. Install the SDK
  2. Update Your Eclipse ADT Plugin
  3. Run Your Applications
  4. Migrate Your Applications

Migrating information

  1. Android 1.6 API Differences

This document describes how to move your development environment and existing Android applications from an Android 1.5 SDK to the Android 1.6 SDK. If you are migrating applications from an SDK older than 1.5, please also read the upgrading document available in the Android 1.5 SDK package.

There are several compelling reasons to upgrade, such as new SDK tools that make developing more efficient and new APIs that allow you to expand the feature-set of your applications. However, even if you or your applications don't require these enhancements, it's important that you upgrade to ensure that your applications run properly on the upcoming Android platform.

The Android 1.6 platform will soon be deployable to devices around the world. If you have already released Android applications to the public, you should test the forward-compatibility of your applications on the latest version of the platform as soon as possible. It's unlikely that you'll encounter problems in your applications, but in the interest of maintaining the best user experience, you should take no risks. So, please install the new Android SDK and test your applications on the new platform.

For more information on new SDK features and system changes, see the Android 1.6 Version Notes.

Install the SDK

If you haven't yet downloaded the SDK, download it from here and unpack it into a safe location.

If you had previously setup your PATH variable to point to the SDK tools directory, then you need to update it to point to the new SDK. For example, for a .bashrc or .bash_profile file:

export PATH=$PATH:<your_sdk_dir>/tools

Update Your Eclipse ADT Plugin

If you don't use the Eclipse IDE for development, skip to Run Your Applications.

A new version of the ADT Plugin, ADT 0.9.3, is available in conjunction with this SDK release. To use the SDK, you must upgrade your ADT Plugin to version 0.9.3. With ADT 0.9.3, you can still compile your existing applications against multiple platform versions, such as Android 1.5, Android 1.1, and so on. However, ADT 0.9.3 is not compatible with previous versions of the SDK and its tools, so make sure that you upgrade both your SDK and the ADT Plugin.

The upgrade steps for ADT are described below. For information about new features in ADT, see the Release Notes document.

If you're currently using a version of ADT older than version 0.9, then you must uninstall ADT before you proceed (read how to Uninstall your previous ADT plugin). If you currently have version 0.9 or 0.9.1, then you don't need to uninstall and can continue with the procedure below.

Eclipse 3.4 (Ganymede)Eclipse 3.5 (Galileo)
  1. Select Help > Software Updates.
  2. Select the Available Software tab.
  3. Select the checkboxes next to Android DDMS and Android Developer Tools, then click Update.
  4. In the resulting Available Updates dialog, ensure that both Android DDMS and Android Development Tools are selected, then click Next.
  5. Read and accept the license agreement and then click Finish. This will download and install the latest version of Android DDMS and Android Development Tools.
  6. Restart Eclipse.
  1. Select Help > Check for Updates.
  2. In the resulting Available Updates dialog, locate the Android DDMS and Android Development Tools features in the list and ensure that the checkboxes next to them are selected. Click Next.

    If the Available Updates dialog does not list Android DDMS and Android Development tools, make sure that you have set up a remote update site for them, as described in Installing the ADT Plugin.

  3. In the Update Details dialog, click Next.
  4. Read and accept the license agreement and then click Finish. This will download and install the latest version of Android DDMS and Android Development Tools.
  5. Restart Eclipse.

If you encounter problems with this update procedure, try performing a fresh installation. Fully remove your existing ADT Plugin as described in Uninstall your previous ADT plugin and then follow the guide to Installing the ADT Plugin for Eclipse.

Update your Eclipse SDK Preferences

The last step is to update your Eclipse preferences to point to the new SDK directory:

  1. Select Window > Preferences to open the Preferences panel (Mac: Eclipse > Preferences ).
  2. Select Android from the left panel.
  3. For the SDK Location, click Browse and locate your SDK directory.
  4. Click Apply, then OK.

Run Your Applications to Test Forward Compatibility

Now that you have installed the Android 1.6 SDK, we encourage you run each of your existing applications on the Android 1.6 system image that is included in the SDK, to ensure that it functions properly on the new platform. Testing forward-compatibility in this way is especially important for applications that you may have already published and that may be installed on devices that will upgrade to the new platform.

In most cases, your applications will function properly when run on the new version of the platform. However, it is possible that you will encounter unexpected behavior, because of changes in the API or underlying platform. If you do find problems, you can use the SDK tools to compile and publish an update to the applications, which users can then download.

To test forward-compatibility, simply run your application, as-is, on an instance of the Android Emulator that uses an AVD targeted to the "Android 1.6" system image. Here are the steps:

  1. Make no changes to your application code.
  2. Create a new AVD that runs the new "Android 1.6" platform.
  3. Launch your application in an emulator running the new AVD.
  4. Perform normal testing on your application to ensure everything works as expected.

Note that, for the purposes of forward-compatibility testing, you should not change how your application is compiled. That is, you should continue to compile the application against the same version of the Android library as before. The only change needed is to the AVD, which controls the version of the Android system image (run-time environment) on which the application is run.

For more information on creating an AVD and launching your application, see Running Your Applications (Eclipse) or Running Your Applications (other IDEs), depending on your development environment.

Android 1.6 Forward-Compatibility Tips

The new version of the Android platform includes several new APIs, but very few actual changes to existing APIs. This means that, in most cases, your applications written with earlier versions of the Android library should run properly on the Android 1.6 platform.

However, here are some areas to pay attention to as you test forward-compatibility:

Migrate Your Applications

If you want to use any of the new Android 1.6 APIs in your existing applications, you must first migrate the applications to the new Android platform version. Generally, migrating an application includes:

Additionally, to run your application in the emulator, you need to create an AVD that uses the Android 1.6 system image.

Note: You only need migrate your application as described in this section if the application will actually use APIs introduced in the Android 1.6 platform (which are not available on devices running older versions of the Android platform). If your application does not use any new APIs, you can compile and run it without modification and not migration is necessary.

Reference the Proper API Level

If your application is using APIs introduced in Android 1.6, you must reference that dependency in the application's manifest file so that it can be deployed to devices running the Android 1.6 platform.

Open the manifest file and locate the minSdkVersion attribute in the <uses-sdk> manifest element. Set the value of minSdkVersion to "4" (the API Level identifier corresponding to Android 1.6). Here's an example:

<manifest>
  ...
  <uses-sdk android:minSdkVersion="4" />
  ...
</manifest>

Compile Against the Proper Build Target

Once you've changed the minSdkVersion value in your application's manifest, you need to set the application's project properties so that the application will be compiled against the Android 1.6 library. To do so, follow the steps below for your respective development environment.

Eclipse Users

  1. Right-click on the individual project (in the Package Explorer) and select Properties.
  2. In the properties, open the Android panel and select a new Project Build Target. Select "Android 1.6" to target the new platform (or "Google APIs" with the "4" API Level, if your application uses the Google Maps APIs).
  3. Click Apply, then OK.

Ant Users

Use the android tool (located in your_sdk/tools/) to create a new build.xml that references the new platform target. To see a list of available targets, execute:

android list targets

Select the target id that corresponds to the "Android 1.6" platform and pass it with the --target parameter when updating your project. For example:

android update project --path /path/to/my-project --target 2

If your application uses the Google Maps APIs (i.e., MapView), be certain to select a Google APIs target.

Create an AVD that Uses the Android 1.6 Platform

Finally, you need to set up a new AVD that uses the Android 1.6 platform, so that you can run your application in the emulator.

To set up the new AVD, use the android tool, available in the tools/ directory of the SDK. You can run the AVD manager by simply changing to the tools/ directory and entering android at the command line. Click "New" to create the AVD and set its properties.

When creating the AVD, make sure to select a target of "Android 1.6 - API Level 4". If your application uses the Google Maps APIs (MapView), select the target "Google APIs (Google Inc.) - API Level 4".

For more information about running your application in an AVD, see Running Your Application (Eclipse) or Running Your Application (other IDEs).

For general information about AVDs, see the Android Virtual Devices document.

If you have trouble migrating to the new version of the SDK, visit the Android Developers Group to seek help from other Android developers.