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