This document describes how to move your development environment and existing Android applications from an Android 1.0 or 1.1 SDK to the Android 1.5 SDK. If you are migrating applications from an SDK older than 1.0, please also read the upgrading document available in the Android 1.0 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 Android 1.5 platform.
The Android 1.5 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 breakage 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 Android 1.5.
For more information on new SDK features and system changes, see the Android 1.5 Version Notes.
If you haven't yet downloaded the SDK, download from here and unpack it into a safe location.
Before you begin: 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
If you don't use Eclipse for development, skip to Update Your Projects.
If you installed ADT-0.9_pre with the early look 1.5 SDK, there have been additional changes, so please continue with this guide and update to the final ADT 0.9.
A new ADT plugin (version 0.9) is required for the Android 1.5 SDK. Because the component structure has been changed since Android 1.1, the Android 1.5 SDK does not work with ADT 0.8 (or older) and previously installed SDKs will not work with ADT 0.9. However, the Android 1.5 SDK includes an Android 1.1 SDK image that you can build against while using ADT 0.9.
For information about using different system images (such as Android 1.1) while running this SDK, see Developing In Eclipse, with ADT or In Other IDEs, as appropriate for your development environment.
In order to upgrade your Eclipse IDE to use the new 0.9 ADT, follow the steps below for your respective version of Eclipse.
You must uninstall your existing ADT plugin (0.8 or older). If you do not uninstall it, you will get a conflict with the Android Editors when installing the new ADT. (If you have already installed ADT-0.9_pre with the early look 1.5 SDK, you can skip this uninstall procedure and continue to Install the 0.9 ADT plugin).
<!-- 3.3 steps -->
|
<!-- 3.4 steps -->
|
Only install the new plugin once you've completed the procedure to Uninstall your previous ADT plugin.
<!-- 3.3 steps -->
|
<!-- 3.4 steps -->
|
If you encounter problems, ensure your ADT is fully uninstalled and then follow the guide to Installing the ADT Plugin for Eclipse.
The last step is to update your Eclipse preferences to point to the new SDK directory:
You will now need to update any and all Android projects that you have developed using a previous version of the Android SDK.
If you use Eclipse to develop applications, use the following procedure to update each project:
The new plugin creates a gen/
folder in your project, in which it puts the R.java
file and all automatically generated AIDL java files. If you get an error such as The type R is already defined
, then you probably need to delete your old R.java
or your old auto-generated AIDL Java files in the src/
folder. (This does not apply to your own hand-crafted parcelable AIDL java files.)
Note that, with the Android 1.5 SDK, there is a new process for running applications in the Android Emulator. Specifically, you must create an Android Virtual Device (AVD) before you can launch an instance of the Emulator. Before attempting to run your applications with the new SDK, please continue with the section below to Migrate Your Applications.
If you build your projects using the Ant tool (rather than with Eclipse), note the following changes with the new SDK tools.
You must re-create your build.xml
file.
If you had customized your build.xml
, first make a copy of it:
$ cd my-project $ cp build.xml build.xml.old
Now use the new android
tool (located in your_sdk/tools/
) to create a new build.xml
that references a specific platform target:
$ android update project --path /path/to/my-project --target 1
The "target" corresponds to an Android platform library (including any add-ons, such as Google APIs) that you would like to build your project against. You can view a list of available targets (and their corresponding integer ID) with the command, android list targets
. When you are initially updating your projects to the new SDK, we recommend that you select the first target ("1"), which uses the Android 1.1 platform library.
A gen/
folder will be created the first time you build and your R.java
and your AIDL Java files will be generated in here. You must remove the old R.java
and old auto-generated AIDL java files from the src/
folder. (This does not apply to your own hand-crafted parcelabe AIDL java files.)
Note: The "activitycreator" tool has been replaced by the new "android" tool. For information on creating new projects with the android tool, see the documentation about Developing In Other IDEs.
Note that, with the Android 1.5 SDK, there is a new process for running applications in the Android Emulator. Specifically, you must create an Android Virtual Device (AVD) before you can launch an instance of the Emulator. Before attempting to run your applications with the new SDK, please continue with the section below to Migrate Your Applications.
After you have completed the process above to Update Your Projects, you are strongly encouraged to run each of your applications in an instance of the emulator running the Android 1.5 system image. It's possible (however, unlikely) that you'll encounter some breakage in your application when you run your applications on the Android 1.5 system image. Whether you believe your application will be affected by platform changes or not, it's very important that you test the application's forward-compatibility on Android 1.5.
To test forward-compatibility, simply run your existing application (as-is) on an Android Emulator that's running the Android 1.5 system image. The following procedure will guide you through the process to running your existing applications on an emulator. Please read the following guide completely before you begin.
To test your application on an emulator running Android 1.5:
As mentioned in the guide to Update Your Projects, you should have selected a "build target" of "1", which compiles your application against the Android 1.1 system image, so there should be no new errors in your code.
Eclipse users: follow the Eclipse guide to Running Your Application.
Ant users: follow the Ant guide to Running Your Application
During the procedure to Running Your Application, select a "deployment target" for the AVD that includes the Android 1.5 platform. If your application utilizes the Google Maps APIs (i.e., MapView), be certain to select a target that includes the Google APIs.
Once you complete the procedures to run your application in your respective environment, linked above, return here.
Chances are, your application runs just fine on the Android 1.5 platform — new devices will be able to safely install and run your application and current users who update their devices will be able to continue using your application as usual. However, if something doesn't work the way you expect, then you might need to revisit your project and make any necessary changes to your code.
You can check for code breakages caused by API changes by opening your project in Eclipse, changing the "build target" to one using the Android 1.5 platform, and see where the ADT identifies errors in your code.
There have been several API additions made for this release, but there have been very few actual API changes. Only a couple (relatively unused) elements have been removed and a few have been deprecated, so your applications written with the Android 1.1 system library should work just fine. However, your application is more likely to encounter problems on Android 1.5 if it performs any of the following:
Please read our blog post on Future-Proofing Your Apps for more information on the issues mentioned above.
For information about other changes made to Android 1.5, refer to the following documents:
If you have additional trouble updating your code, visit the Android Developers Group to seek help from other Android developers.