`
BlogDown
  • 浏览: 212079 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

怎样更新Android SDK1.1 到 Android SDK1.5

 
阅读更多

Upgrading the SDK

Upgrading the SDK

  • The Android 1.5 SDK uses a new project structure and a new ADT plugin (ADT 0.9).
  • To move existing projects into the SDK, you must make some minor changes in your development environment.
  • The new ADT plugin (ADT 0.9) is not compatible with projects created in previous SDKs.
  • You need to uninstall your existing ADT plugin, before installing ADT 0.9.

In this document

  1. Install the SDK
  2. Update Your Eclipse ADT Plugin
  3. Update Your Projects
    1. Eclipse Users
    2. Ant Users
  4. Migrate Your Applications
    1. Future-proof your apps

Migrating references

  1. Android 1.5 API Differences
  2. Future-Proofing Your Apps »
  3. UI framework changes in Android 1.5 »

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.

Install the SDK

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.

Update Your Eclipse ADT Plugin

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.

Uninstall your previous ADT plugin

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).

Eclipse 3.3 (Europa) Eclipse 3.4 (Ganymede)
<!-- 3.3 steps -->
  1. Select Help > Software Updates > Manage Configuration.
  2. Expand the list in the left panel to reveal the installed tools.
  3. Right-click "Android Editors" and click Uninstall. Click OK to confirm.
  4. Restart Eclipse.

    (Do not uninstall "Android Development Tools".)

<!-- 3.4 steps -->
  1. Select Help > Software Updates.
  2. Select the Installed Software tab.
  3. Select "Android Editors". Click Uninstall.
  4. In the next window, be sure "Android Editors" is checked, then click Finish to uninstall.
  5. Restart Eclipse.

    (Do not uninstall "Android Development Tools".)

Install the 0.9 ADT plugin

Only install the new plugin once you've completed the procedure to Uninstall your previous ADT plugin.

Eclipse 3.3 (Europa) Eclipse 3.4 (Ganymede)
<!-- 3.3 steps -->
  1. Select Help > Software Updates > Find and Install.
  2. Select Search for new features to install.
  3. Select the Android plugin entry by checking the box next to it, then click Finish.

    (Your original entry for the plugin should still be here. If not, see the guide to Installing the ADT Plugin.)

  4. In the results, expand the entry for the Android plugin and be sure that "Developer Tools" is checked, then click Next. (This will install "Android DDMS" and "Android Development Tools".)
  5. Read and accept the license agreement, then click Next.
  6. In the next window, click Finish to start installation.
  7. The ADT plugin is not digitally signed. Accept the installation anyway by clicking Install All.
  8. Restart Eclipse.
<!-- 3.4 steps -->
  1. Select Help > Software Updates.
  2. Select the Available Software tab.
  3. Expand the entry for the Andriod plugin (may be listed as the location URL) and select "Developer Tools" by checking the box next to it, then click Install.
  4. On the next window, "Android DDMS" and "Android Development Tools" should both be checked. Click Finish.
  5. Restart Eclipse.

If you encounter problems, ensure your ADT is fully uninstalled 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 in the main panel, click Browse and locate your SDK directory.
  4. Click Apply, then OK.

Update Your Projects

You will now need to update any and all Android projects that you have developed using a previous version of the Android SDK.

Eclipse users

If you use Eclipse to develop applications, use the following procedure to update each project:

  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 "build target" to compile against. This SDK offers the Android 1.1 and Android 1.5 platforms to choose from. When you are initially updating your projects to the new SDK, we recommend that you select a build target with the Android 1.1 platform. Click Apply, then OK.

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.

Ant users

If you build your projects using the Ant tool (rather than with Eclipse), note the following changes with the new SDK tools.

build.xml has changed

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.

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:

  1. Update Your Project (you should have done this already, in the section above).
  2. Run your existing project, as-is, on an emulator running the Android 1.5 system image.

    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.

  3. With your application running in the emulator, perform all regular testing on the application to ensure that it functions normally (in both landscape and portrait orientations).

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.

Future-proof your apps

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:

  • Uses internal APIs. That is, APIs that are not officially supported and not available in the reference documentation. Any un-official APIs are always subject to change (which is why they're un-official) and some have indeed changed.
  • Directly manipulates system settings. There are some settings (such as GPS, data roaming, bluetooth and others) that used to be writable by applications but have been changed so that they can only be explicitly modified by the user through the system settings. Refer to Settings.Secure to see which settings are now secured and cannot be directly changed by your application.
  • Uses View hierarchies that are unreasonably deep (more than 10 or so levels) or broad (more than 30 total). View hierarchies this big have always been troublesome, but Android 1.5 is much more efficient at exposing this and your application may crash.
  • Makes assumptions about the available hardware. With new support for soft keyboards, not all devices will have full QWERTY keyboards on the hardware. So if your application listens for special keypress events that only occur on a keypad, then your application should degrade gracefully when there is no keyboard available.
  • Performs its own layout orientation changes based on the acceletometer (or via other sensors). Some devices running Android 1.5 will automatically rotate the orientation (and all devices have the option to turn on auto-rotation), so if your application also attempts to rotate the orientation, it can result in strange behavior. In addition, if your application uses the accelerometer to detect shaking and you do not want to rotate the orientation, then you should lock the current orientation with android:screenOrientation.

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.

分享到:
评论

相关推荐

    android sdk 1.1.part2

    android sdk 1.1.part2 共两个压缩包

    android sdk 1.1.part1

    android sdk 1.1 part1共分两部分

    ArcGIS Runtime SDK for Android v1.1

    ArcGIS Runtime SDK for Android v1.1发布啦,增强和改进如下: API: 1、从ArcGIS.com上搜索和使用content、users和groups; 2、支持要素定义存储在本地设备上的要素的高级符号化渲染; 3、支持单个应用程序中多个...

    Google AndroidSDK开发范例大全 4( under_1.5SDK_Compile)

    光盘中附上了两份程序代码文件,android-under_1.1SDK_Compile目录下的程序可以直接在1.1环境下运行,而android-under_1.5SDK_Compile目录下的程序可以直接在1.5环境下运行: 1. android-under_1.1SDK_Compile目录...

    GoogleAndroidSDK开发范例大全 3(under_1.5SDK_Compile)

    光盘中附上了两份程序代码文件,android-under_1.1SDK_Compile目录下的程序可以直接在1.1环境下运行,而android-under_1.5SDK_Compile目录下的程序可以直接在1.5环境下运行: 1. android-under_1.1SDK_Compile目录...

    Android SDK开发包国内官网下载地址.pdf

    不知道是因为最近kaihui还是怎么的,打开android sdk官方网站特别的慢,想下载最新版本的platform几乎变成不可能完成的任务,不知道为什么Google不像Apache那样在各国设立镜像站。为了预防今后再出现这样的情况,...

    Google AndroidSDK开发范例大全2

    光盘中附上了两份程序代码文件,android-under_1.1SDK_Compile目录下的程序可以直接在1.1环境下运行,而android-under_1.5SDK_Compile目录下的程序可以直接在1.5环境下运行: 1. android-under_1.1SDK_Compile目录...

    Google AndroidSDK开发范例大全 1

    光盘中附上了两份程序代码文件,android-under_1.1SDK_Compile目录下的程序可以直接在1.1环境下运行,而android-under_1.5SDK_Compile目录下的程序可以直接在1.5环境下运行: 1. android-under_1.1SDK_Compile目录...

    百度离线识别SDK1.1 demo

    解决百度人脸识别之离线识别SDK1.1demo编译失败和运行失败的问题,gradel3.4的implementation、api、complile区别,技术交流QQ:774908055

    android-sdk-windows-1.1_r1

    是关于gphone开发使用的android包

    Android SDK r14离线安装包

    Android SDK r14离线安装包 1、基础包------ android-sdk_r14-windows_1.zip 包含:Tools Android SDK Tools Android SDK Platform-tools Extras Android Support package Google Admob Ads Sdk package ...

    sdk-android-1.1.66

    android_navigator.zip,为活动创建意图时删除样板Android意图变得简单!!!!

    sdk-android-1.1.66.zip

    android_sdk.zip,Genesis Android SDKgenesis Android软件开发包

    《Google Android SDK开发范例大全(第3版)》.pdf

     《google android sdk开发范例大全(第3版)》内容由android的基础知识到实际开发应用,结构清晰、语言简洁,非常适合android的初学者和android的进阶程序开发者阅读参考。 目录 《google android sdk开发范例...

    google Android SDK 开发范例大全 第一版 源码(1.1部分)

    《google Android SDK 开发范例大全(配套光盘)(余志龙等 编著 人民邮电出版社)》 源代码分为 android-under_1.1SDK_Compile 和 android-under_1.5SDK_Compile 这是1.1的 因为上传权限不够 只能分开上传

    Google Android SDK开发范例大全(PDF完整版4)(4-4)

    2.1 安装AndroidSDK与ADTplug-in 2.2 建立第一个Android项目(HelloAndroid!) 2.3 Android应用程序架构——从此开始 2.4 可视化的界面开发工具 2.5 部署应用程序到Android手机 第3章 用户人机界面 3.1 更改与显示...

    google Android SDK 开发范例大全 第一版 源码(1.5部分)

    《google Android SDK 开发范例大全(配套光盘)(余志龙等 编著 人民邮电出版社)》 ...android-under_1.1SDK_Compile 和 android-under_1.5SDK_Compile 这是1.5的 因为上传权限不够 只能分开上传

Global site tag (gtag.js) - Google Analytics