Home | History | Annotate | Download | only in 1.5_r3
      1 page.title=Upgrading the SDK
      2 sdk.version=1.5
      3 sdk.rel.id=3
      4 
      5 @jd:body
      6 
      7 
      8 <div id="qv-wrapper">
      9 <div id="qv">
     10 
     11   <h2>Upgrading the SDK</h2>
     12   <ul>
     13     <li>The Android 1.5 SDK uses a new project structure and a new ADT plugin (ADT 0.9). </li>
     14     <li>To move existing projects into the SDK, you must make some minor changes in your 
     15     development environment.</li>
     16     <li>The new ADT plugin (ADT 0.9) <em>is not compatible</em> with projects created in previous SDKs.</li>
     17     <li>You need to uninstall your existing ADT plugin, before installing ADT 0.9.</li>
     18   </ul>
     19 
     20   <h2>In this document</h2>
     21   <ol>
     22     <li><a href="#Install">Install the SDK</a></li>
     23     <li><a href="#UpdateAdt">Update Your Eclipse ADT Plugin</a></li>
     24     <li><a href="#UpdateYourProjects">Update Your Projects</a>
     25       <ol>
     26         <li><a href="#EclipseUsers">Eclipse Users</a></li>
     27         <li><a href="#AntUsers">Ant Users</a></li>
     28       </ol>
     29     </li>
     30     <li><a href="#MigrateYourApplications">Migrate Your Applications</a>
     31       <ol><li><a href="#FutureProofYourApps">Future-proof your apps</a></li></ol>
     32     </li>
     33   </ol>
     34   
     35   <h2>Migrating references</h2>
     36   <ol>
     37     <li><a href="{@docRoot}sdk/api_diff/3/changes.html">Android 1.5 API Differences</a></li>
     38     <li><a 
     39 href="http://android-developers.blogspot.com/2009/04/future-proofing-your-apps.html">Future-Proofing
     40 Your Apps &raquo;</a></li>
     41     <li><a 
     42 href="http://android-developers.blogspot.com/2009/04/ui-framework-changes-in-android-15.html">UI 
     43 framework changes in Android 1.5 &raquo;</a></li>
     44   </ol>
     45 
     46 </div>
     47 </div>
     48 
     49 <p>This document describes how to move your development environment and existing
     50 Android applications from an Android 1.0 or 1.1 SDK to the Android 1.5 SDK.
     51 If you are migrating applications from an SDK older than 1.0, please also read the upgrading
     52 document available in the Android 1.0 SDK package.</p>
     53 
     54 <p>There are several compelling reasons to upgrade, such as new SDK tools
     55 that make developing more efficient and new APIs that allow you to expand the feature-set
     56 of your applications. However, even if you or your applications don't require these enhancements,
     57 it's important that you upgrade to ensure that your applications run properly on the 
     58 Android 1.5 platform.</p>
     59 
     60 <p>The Android 1.5 platform will soon be deployable to devices around the world.
     61 If you have already released Android applications to the public, you should
     62 test the forward-compatibility of your applications on the latest version of the platform
     63 as soon as possible. It's unlikely that you'll encounter breakage in your applications, but
     64 in the interest of maintaining the best user experience, you should take no risks.
     65 So, please install the new Android SDK and test your applications on Android 1.5.</p>
     66 
     67 <p>For more information on new SDK features and system changes, 
     68 see the <a href="{@docRoot}sdk/android-1.5.html">Android 1.5 Version Notes</a>.</p>
     69 
     70 
     71 <h2 id="Install">Install the SDK</h2>
     72 
     73 <p>If you haven't yet downloaded the SDK, <a href="index.html">download from here</a> 
     74 and unpack it into a safe location.</p>
     75 
     76 <p><strong>Before you begin:</strong>
     77 If you had previously setup your PATH variable to point to the SDK tools directory, 
     78 then you need to update it to point to the new SDK. For example, for a 
     79 <code>.bashrc</code> or <code>.bash_profile</code> file:</p>
     80 <pre>export PATH=$PATH:<em>&lt;your_sdk_dir></em>/tools</pre>
     81 
     82 <p>If you don't use Eclipse for development,
     83 skip to <a href="#updateYourProjects">Update Your Projects</a>.</p>
     84 
     85 
     86 <h2 id="UpdateAdt">Update Your Eclipse ADT Plugin</h2>
     87 
     88 <p><em>If you installed ADT-0.9_pre with the early look 1.5 SDK, there have been
     89 additional changes, so please continue with this guide and update to the final ADT 0.9.</em></p>
     90 
     91 <p>A new ADT plugin (version 0.9) is required for the Android 1.5 SDK.
     92 Because the component structure has been changed since Android 1.1, 
     93 the Android 1.5 SDK does not work with ADT 0.8 (or older) and previously installed SDKs will not
     94 work with ADT 0.9. However, the Android 1.5 SDK includes an Android 1.1 SDK image that you
     95 can build against while using ADT 0.9. </p>
     96 
     97 <p class="note">For information about using different system images (such as Android 1.1) 
     98 while running this SDK, see Developing <a href="{@docRoot}guide/developing/eclipse-adt.html">
     99 In Eclipse, with ADT</a> or <a href="{@docRoot}guide/developing/other-ide.html">In 
    100 Other IDEs</a>, as appropriate for your development environment.</p>
    101 
    102 <p>In order to upgrade your Eclipse IDE to use the new 0.9 ADT, follow the steps below
    103 for your respective version of Eclipse.</p>
    104 
    105 <h3 id="uninstallAdt">Uninstall your previous ADT plugin</h3>
    106 
    107 <p>You must uninstall your existing ADT plugin (0.8 or older). If you do not uninstall it,
    108 you will get a conflict with the Android Editors when installing the new ADT.
    109 (If you have already installed ADT-0.9_pre with the early look 1.5 SDK, you can skip this
    110 uninstall procedure and continue to <a href="#installAdt">Install the 0.9 ADT plugin</a>).</p>
    111 
    112 <table style="font-size:100%">
    113 <tr><th>Eclipse 3.3 (Europa)</th><th>Eclipse 3.4 (Ganymede)</th></tr>
    114 <tr>
    115 <td width="50%">
    116 <!-- 3.3 steps -->
    117 <ol>
    118     <li>Select <strong>Help</strong> &gt; <strong>Software Updates</strong> &gt; 
    119       <strong>Manage Configuration</strong>. </li>
    120     <li>Expand the list in the left panel to reveal the installed tools.</li>
    121     <li>Right-click "Android Editors" and click <strong>Uninstall</strong>. Click <strong>OK</strong> 
    122     to confirm.</li>
    123     <li>Restart Eclipse. 
    124       <p>(Do not uninstall "Android Development Tools".)</p></li>
    125 </ol>
    126 </td>
    127 <td>
    128 <!-- 3.4 steps -->
    129 <ol>
    130     <li>Select <strong>Help</strong> &gt; <strong>Software Updates</strong>.</li>
    131     <li>Select the <strong>Installed Software</strong> tab.</li>
    132     <li>Select "Android Editors". Click <strong>Uninstall</strong>.</li>
    133     <li>In the next window, be sure "Android Editors" is checked, then click <strong>Finish</strong>
    134     to uninstall.</li>
    135     <li>Restart Eclipse.
    136       <p>(Do not uninstall "Android Development Tools".)</p></li>
    137 </ol>
    138 </td>
    139 </tr>
    140 </table>
    141 
    142 
    143 <h3 id="installAdt">Install the 0.9 ADT plugin</h3>
    144 
    145 <p>Only install the new plugin once you've completed the procedure to
    146 <a href="#uninstallAdt">Uninstall your previous ADT plugin</a>.</p>
    147 
    148 <table style="font-size:100%">
    149 <tr><th>Eclipse 3.3 (Europa)</th><th>Eclipse 3.4 (Ganymede)</th></tr>
    150 <tr>
    151 <td width="50%">
    152 <!-- 3.3 steps -->
    153 <ol>
    154     <li>Select <strong>Help</strong> &gt; <strong>Software Updates</strong> &gt; 
    155       <strong>Find and Install</strong>. </li>
    156     <li>Select <strong>Search for new features to install</strong>.</li>
    157     <li>Select the Android plugin entry by checking the box next to it, 
    158       then click <strong>Finish</strong>.
    159       <p>(Your original entry for the plugin should still be here. If not, see the guide
    160       to <a href="installing.html#installingplugin">Installing the ADT Plugin</a>.)
    161       </p></li>
    162     <li>In the results, expand the entry for the Android plugin and
    163       be sure that "Developer Tools" is checked, then click <strong>Next</strong>.
    164       (This will install "Android DDMS" and "Android Development Tools".)</li>
    165     <li>Read and accept the license agreement, then click <strong>Next</strong>.
    166     <li>In the next window, click <strong>Finish</strong> to start installation.</li>
    167     <li>The ADT plugin is not digitally signed. Accept the installation anyway by clicking 
    168     <strong>Install All</strong>.</li>
    169     <li>Restart Eclipse.</li>
    170 </ol>
    171 </td>
    172 <td>
    173 <!-- 3.4 steps -->
    174 <ol>
    175     <li>Select <strong>Help</strong> &gt; <strong>Software Updates</strong>.</li>
    176     <li>Select the <strong>Available Software</strong> tab.</li>
    177     <li>Expand the entry for the Android plugin (may be listed as the location URL)
    178       and select "Developer Tools" by checking the box next to it, then click 
    179       <strong>Install</strong>.</li>
    180     <li>On the next window, "Android DDMS" and "Android Development Tools" 
    181     should both be checked. Click <strong>Finish</strong>.</li>
    182     <li>Restart Eclipse.</li>
    183 </ol>
    184 </td>
    185 </tr>
    186 </table>
    187 
    188 <p>If you encounter problems, ensure your ADT is fully uninstalled and then
    189 follow the guide to 
    190 <a href="installing.html#installingplugin">Installing the ADT Plugin
    191 for Eclipse</a>.</p>
    192 
    193 <h3 id="updateEclipsePrefs">Update your Eclipse SDK Preferences</h3>
    194 
    195 <p>The last step is to update your Eclipse preferences to point to the new SDK directory:</p>
    196     <ol>
    197       <li>Select <strong>Window</strong> > <strong>Preferences</strong> to open the Preferences 
    198       panel (Mac: <strong>Eclipse</strong> > <strong>Preferences</strong>).</li>
    199       <li>Select <strong>Android</strong> from the left panel.</li>
    200       <li>For the <em>SDK Location</em> in the main panel, click <strong>Browse</strong> 
    201       and locate your SDK directory.</li>
    202       <li>Click <strong>Apply</strong>, then <strong>OK</strong>.</li>
    203     </ol>
    204 
    205 
    206 <h2 id="UpdateYourProjects">Update Your Projects</h2>
    207 
    208 <p>You will now need to update any and all Android projects that you have
    209 developed using a previous version of the Android SDK.</p>
    210 
    211 
    212 <h3 id="EclipseUsers">Eclipse users</h3>
    213 
    214 <p>If you use Eclipse to develop applications, use the following procedure to 
    215 update each project:</p>
    216 
    217 <ol>
    218   <li>Right-click on the individual project (in the Package Explorer)
    219    and select <strong>Properties</strong>.</li>
    220   <li>In the properties, open the Android panel and select a "build target" to compile 
    221     against. This SDK offers the Android 1.1 and Android 1.5 platforms to choose from. When 
    222     you are initially updating your projects to the new SDK, we recommend that you select a build 
    223     target with the Android 1.1 platform. Click <strong>Apply</strong>, then 
    224     <strong>OK</strong>.</li>
    225 </ol>
    226 
    227 <p>The new plugin creates a <code>gen/</code> folder in your project, in which it puts the 
    228 <code>R.java</code> file
    229 and all automatically generated AIDL java files. If you get an error such as 
    230 <code>The type R is already defined</code>, 
    231 then you probably need to delete your old <code>R.java</code> or your old auto-generated
    232 AIDL Java files in the <code>src/</code> folder.
    233 (This <em>does not</em> apply to your own hand-crafted parcelable AIDL java files.)</p>
    234 
    235 <p>Note that, with the Android 1.5 SDK, there is a new process for running 
    236 applications in the Android Emulator. 
    237 Specifically, you must create an Android Virtual Device (AVD) before you can launch an instance
    238 of the Emulator. Before attempting to run your applications with the new SDK, 
    239 please continue with the section below to 
    240 <a href="#MigrateYourApplications">Migrate Your Applications</a>.</p>
    241 
    242 
    243 <h3 id="AntUsers">Ant users</h3>
    244 
    245 <p>If you build your projects using the Ant tool (rather than with Eclipse), note the 
    246 following changes with the new SDK tools.</p>
    247 
    248 <h4>build.xml has changed</h4>
    249 
    250 <p>You must re-create your <code>build.xml</code> file.</p>
    251 
    252 <p>If you had customized your <code>build.xml</code>, first make a copy of it:</p>
    253 
    254 <pre>
    255 $ cd <em>my-project</em>
    256 $ cp build.xml build.xml.old
    257 </pre>
    258 
    259 <p>Now use the new <code>android</code> tool (located in <code><em>your_sdk</em>/tools/</code>) 
    260 to create a new <code>build.xml</code> that references 
    261 a specific platform target:</p>
    262 
    263 <pre>$ android update project --path /path/to/my-project --target 1</pre>
    264 
    265 <p>The "target" corresponds to an Android platform library (including any add-ons, such as 
    266 Google APIs) that you would like to build your project against. You can view a list of available 
    267 targets (and their corresponding integer ID) with the command, <code>android list targets</code>. 
    268 When you are initially updating your projects to the new SDK, we recommend that you select the 
    269 first target ("1"), which uses the Android 1.1 platform library.</p>
    270 
    271 <p>A <code>gen/</code> folder will be created the first time you build and your <code>R.java</code> and
    272 your AIDL Java files will be generated in here. You <strong>must</strong> remove
    273 the old <code>R.java</code> and old auto-generated AIDL java files from the 
    274 <code>src/</code> folder. (This
    275 does not apply to your own hand-crafted parcelable AIDL java files.)</p>
    276 
    277 <p class="note"><strong>Note:</strong> The "activitycreator" tool has been replaced 
    278 by the new "android" tool. For information on creating new projects with the android tool,
    279 see the documentation about <a href="{@docRoot}guide/developing/other-ide.html">Developing 
    280 In Other IDEs</a>.</p>
    281 
    282 <p>Note that, with the Android 1.5 SDK, there is a new process for running 
    283 applications in the Android Emulator. 
    284 Specifically, you must create an Android Virtual Device (AVD) before you can launch an instance
    285 of the Emulator. Before attempting to run your applications with the new SDK, 
    286 please continue with the section below to 
    287 <a href="#MigrateYourApplications">Migrate Your Applications</a>.</p>
    288 
    289 
    290 <h2 id="MigrateYourApplications">Migrate Your Applications</h2>
    291 
    292 <p>After you have completed the process above to <a href="#UpdateYourProjects">Update Your 
    293 Projects</a>, you are strongly encouraged to run each of your applications in an instance
    294 of the emulator running the Android 1.5 system image. It's possible (however, unlikely) 
    295 that you'll encounter some breakage in your application when you run your applications on
    296 the Android 1.5 system image. Whether you believe your application will be affected by 
    297 platform changes or not, it's very important that you test the application's 
    298 forward-compatibility on Android 1.5.</p>
    299 
    300 <p>To test forward-compatibility, simply run your existing application (as-is) on an Android
    301 Emulator that's running the Android 1.5 system image. The following procedure will guide
    302 you through the process to running your existing applications on an emulator. <em>Please read
    303 the following guide completely before you begin</em>.</p>
    304 
    305 <p>To test your application on an emulator running Android 1.5:</p>
    306 <ol>
    307   <li><a href="#UpdateYourProjects">Update Your Project</a> (you should have done this 
    308   already, in the section above).</li>
    309   <li>Run your existing project, as-is, on an emulator running the Android 1.5 system image.
    310     <p>As mentioned in the guide to <a href="#UpdateYourProjects">Update Your Projects</a>, 
    311     you should have selected a "build
    312     target" of "1", which compiles your application against the Android 1.1 system image, so there
    313     should be no new errors in your code.</p>
    314     <p>Eclipse users: follow the 
    315     <a href="{@docRoot}guide/developing/eclipse-adt.html#Running">Eclipse guide to 
    316     Running Your Application</a>.</p>
    317     <p>Ant users: follow the 
    318     <a href="{@docRoot}guide/developing/other-ide.html#Running">Ant guide to 
    319     Running Your Application</a>
    320     <p>During the procedure to Running Your Application, select a "deployment target" 
    321     for the AVD that includes the Android 1.5 platform. 
    322     If your application utilizes the Google Maps APIs (i.e.,
    323     MapView), be certain to select a target that includes the Google APIs.</p>
    324     <p>Once you complete the procedures to run your application in your respective environment,
    325     linked above, return here.</p>
    326   </li>
    327   <li>With your application running in the emulator, perform all regular testing on the application
    328   to ensure that it functions normally (in both landscape and portrait orientations).</li>
    329 </ol>
    330 
    331 <p>Chances are, your application runs just fine on the Android 1.5 platform &mdash; 
    332 new devices will be able to safely install and run your application and
    333 current users who update their devices will be able to continue using your application as usual.
    334 However, if something doesn't work the way you expect, then you might need to revisit
    335 your project and make any necessary changes to your code.</p>
    336 
    337 <p>You can check for code breakages caused by API changes by opening your project 
    338 in Eclipse, changing the "build target" to one using the Android 1.5 platform,
    339 and see where the ADT identifies errors in your code.</p>
    340 
    341 
    342 <h3 id="FutureProofYourApps">Future-proof your apps</h3>
    343 
    344 <p>There have been several API additions made for this release, but there have been
    345 very few actual API <em>changes</em>. Only a couple (relatively unused) elements 
    346 have been removed and a few have been deprecated, so your applications written with the 
    347 Android 1.1 system library should work just fine. However, 
    348 your application is more likely to encounter problems on Android 1.5
    349 if it performs any of the following:</p>
    350 
    351 <ul>
    352   <li>Uses internal APIs. That is, APIs that are not officially supported
    353   and not available in the reference documentation. Any un-official APIs are always subject
    354   to change (which is why they're un-official) and some have indeed changed.
    355   </li>
    356   <li>Directly manipulates system settings. There are some settings (such as
    357   GPS, data roaming, bluetooth and others) that used to be writable by 
    358   applications but have been changed so that they can only be explicitly modified by the user
    359   through the system settings. Refer to {@link android.provider.Settings.Secure}
    360   to see which settings are now secured and cannot be directly changed by your application.
    361   </li>
    362   <li>Uses View hierarchies that are unreasonably deep (more than 10 or so levels) or 
    363   broad (more than 30 total). View hierarchies this big have always been troublesome, but 
    364   Android 1.5 is much more efficient at exposing this and your application may crash.
    365   </li>
    366   <li>Makes assumptions about the available hardware. With new support for soft keyboards,
    367   not all devices will have full QWERTY keyboards on the hardware. So if your application
    368   listens for special keypress events that only occur on a keypad, then your application
    369   should degrade gracefully when there is no keyboard available.
    370   </li>
    371   <li>Performs its own layout orientation changes based on the accelerometer (or via other
    372   sensors). Some devices running Android 1.5 will automatically rotate the orientation
    373   (and all devices have the option to turn on auto-rotation), so if your application also
    374   attempts to rotate the orientation, it can result in strange behavior. In addition, if your
    375   application uses the accelerometer to detect shaking and you do not want to rotate the 
    376   orientation, then you should lock the current orientation with 
    377   <a href="{@docRoot}guide/topics/manifest/activity-element.html#screen">android:screenOrientation</a>.
    378   </li>
    379 </ul>
    380 
    381 <p>Please read our blog post on <a 
    382 href="http://android-developers.blogspot.com/2009/04/future-proofing-your-apps.html">Future-Proofing
    383 Your Apps</a> for more information on the issues mentioned above.</p>
    384 
    385 <p>For information
    386 about other changes made to Android 1.5, refer to the following documents:</p>
    387 <ul>
    388   <li><a href="{@docRoot}sdk/api_diff/3/changes.html">Android 1.5 API Differences</a></li>
    389   <li><a href="{@docRoot}sdk/android-1.5.html#api-changes">Android 1.5 Version Notes</a></li> 
    390   <li><a 
    391 href="http://android-developers.blogspot.com/2009/04/ui-framework-changes-in-android-15.html">UI 
    392 framework changes in Android 1.5 &raquo;</a></li>
    393 </ul>
    394 
    395 <p>If you have additional trouble updating your code, visit the 
    396 <a href="http://groups.google.com/group/android-developers">Android Developers Group</a>
    397 to seek help from other Android developers.</p>
    398