1 page.title=Preparing for Release 2 @jd:body 3 4 <div id="qv-wrapper"> 5 <div id="qv"> 6 <h2>Quickview</h2> 7 <ul> 8 <li>Learn which resources you'll need to release your app.</li> 9 <li>Find out how to configure and build your app for release.</li> 10 <li>Learn best practices for releasing your app.</li> 11 </ul> 12 <h2>In this document</h2> 13 <ol> 14 <li><a href="#publishing-intro">Introduction</a></li> 15 <li><a href="#publishing-gather">Gathering Materials and Resources</a></li> 16 <li><a href="#publishing-configure">Configuring Your Application</a></li> 17 <li><a href="#publishing-build">Building Your Application</a></li> 18 <li><a href="#publishing-resources">Preparing External Servers and Resources</a></li> 19 <li><a href="#publishing-test">Testing Your Application for Release</a></li> 20 </ol> 21 <h2>See also</h2> 22 <ol> 23 <li><a href="{@docRoot}guide/publishing/publishing_overview.html">Publishing Overview</a></li> 24 <li><a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a></li> 25 <li><a href="{@docRoot}guide/publishing/publishing.html">Publishing on Android Market</a></li> 26 </ol> 27 </div> 28 </div> 29 30 <p>Before you distribute your Android application to users you need to prepare it for release. The 31 preparation process is a required <a href="{@docRoot}guide/developing/index.html">development 32 task</a> for all Android applications and is the first step in the publishing process (see figure 33 1).</p> 34 35 <p>When you prepare your application for release, you configure, build, and test a release 36 version of your application. The configuration tasks are straightforward, involving basic code 37 cleanup and code modification tasks that help optimize your application. The build process is 38 similar to the debug build process and can be done using JDK and Android SDK tools. The testing 39 tasks serve as a final check, ensuring that your application performs as expected under real-world 40 conditions. When you are finished preparing your application for release you have a signed 41 <code>.apk</code> file, which you can distribute directly to users or distribute through an 42 application marketplace such as Android Market.</p> 43 44 <p>This document summarizes the main tasks you need to perform to prepare your application for 45 release. The tasks that are described in this document apply to all Android applications regardless 46 how they are released or distributed to users. If you are releasing your application through Android 47 Market, you should also read <a href="{@docRoot}guide/publishing/publishing.html">Publishing on 48 Android Market</a> to be sure your release-ready application satisfies all Android Market 49 requirements.</p> 50 51 <p class="note"><strong>Note:</strong> As a best practice, your application should meet all of your 52 release criteria for functionality, performance, and stability before you perform the tasks outlined 53 in this document.</p> 54 55 <img src="{@docRoot}images/publishing/publishing_overview_prep.png" 56 alt="Shows how the preparation process fits into the development process" 57 height="190" 58 id="figure1" /> 59 <p class="img-caption"> 60 <strong>Figure 1.</strong> Preparing for release is a required <a 61 href="{@docRoot}guide/developing/index.html">development 62 task</a> and is the first step in the publishing process. 63 </p> 64 65 <h2 id="publishing-intro">Introduction</h2> 66 67 <p>To release your application to users you need to create a release-ready package that users can 68 install and run on their Android-powered devices. The release-ready package contains the same 69 components as the debug <code>.apk</code> file — compiled source code, resources, manifest 70 file, and so on — and it is built using the same build tools. However, unlike the debug 71 <code>.apk</code> file, the release-ready <code>.apk</code> file is signed with your own certificate 72 and it is optimized with the zipalign tool.</p> 73 74 <div class="figure" style="width:331px"> 75 <img src="{@docRoot}images/publishing/publishing_preparing.png" 76 alt="Shows the five tasks you perform to prepare your app for release" 77 height="450" /> 78 <p class="img-caption"> 79 <strong>Figure 2.</strong> You perform five main tasks to prepare your application for 80 release. 81 </p> 82 </div> 83 84 <p>The signing and optimization tasks are usually seamless if you are building your application with 85 Eclipse and the ADT plugin or with the Ant build script (included with the Android SDK). For 86 example, you can use the Eclipse Export Wizard to compile, sign, and optimize your application all 87 at once. You can also configure the Ant build script to do the same when you build from the command 88 line.</p> 89 90 <p>To prepare your application for release you typically perform five main tasks (see figure 2). 91 Each main task may include one or more smaller tasks depending on how you are releasing your 92 application. For example, if you are releasing your application through Android Market you may want 93 to add special filtering rules to your manifest while you are configuring your application for 94 release. Similarly, to meet Android Market publishing guidelines you may have to prepare screenshots 95 and create promotional text while you are gathering materials for release.</p> 96 97 <p>You usually perform the tasks listed in figure 2 after you have throroughly debugged and tested 98 your application. The Android SDK contains several tools to help you test and debug your Android 99 applications. For more information, see the <a 100 href="{@docRoot}guide/developing/debugging/index.html">Debugging</a> and <a 101 href="{@docRoot}guide/developing/testing/index.html">Testing</a> sections in the Dev Guide.</p> 102 103 <h2 id="publishing-gather">Gathering Materials and Resources</h2> 104 105 <p>To begin preparing your application for release you need to gather several supporting items. At a 106 minimum this includes cryptographic keys for signing your application and an application icon. You 107 might also want to include an end-user license agreement.</p> 108 109 <h4 id="publishing-keys">Cryptographic keys</h4> 110 111 <p>The Android system requires that each installed application be digitally signed with a 112 certificate that is owned by the application's developer (that is, a certificate for which the 113 developer holds the private key). The Android system uses the certificate as a means of identifying 114 the author of an application and establishing trust relationships between applications. The 115 certificate that you use for signing does not need to be signed by a certificate authority; the 116 Android system allows you to sign your applications with a self-signed certificate. To learn about 117 certificate requirements, see <a href="{@docRoot}guide/publishing/app-signing.html#cert">Obtain a 118 suitable private key</a>.</p> 119 120 <p>You may also have to obtain other release keys if your application accesses a service or uses a 121 third-party library that requires you to use a key that is based on your private key. For example, 122 if your application uses the <a 123 href="http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/ MapView. 124 html">MapView</a> class, which is part of the <a 125 href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google Maps external 126 library</a>, you will need to register your application with the Google Maps service and obtain 127 a Maps API key. For information about getting a Maps API key, see <a 128 href="http://code.google.com/android/add-ons/google-apis/mapkey.html"> Obtaining a Maps API 129 key</a>.</p> 130 131 <h4>Application Icon</h4> 132 133 <p>Be sure you have an application icon and that it meets the recommended <a 134 href="{@docRoot}guide/practices/ui_guidelines/icon_design_launcher.html">icon guidelines</a>. Your 135 application's icon helps users identify your application on a device's Home 136 screen and in the Launcher window. It also appears in Manage Applications, My Downloads, and 137 elsewhere. In addition, publishing services such as Android Market display your icon to users.</p> 138 139 <p class="note"><strong>Note:</strong> If you are releasing your application on Android Market, you 140 need to create a high resolution 141 version of your icon. See <a 142 href="https://www.google.com/support/androidmarket/developer/bin/answer.py?answer=1078870">Graphic 143 Assets for your Application</a> for more information.</p> 144 145 <h4>End-user License Agreement</h4> 146 147 <p>Consider preparing an End User License Agreement (EULA) for your application. A EULA can help 148 protect your person, organization, and intellectual property, and we recommend that you provide one 149 with your application.</p> 150 151 <h4>Miscellaneous Materials</h4> 152 153 <p>You might also have to prepare promotional and marketing materials to publicize your application. 154 For example, if you are releasing your application on Android Market you will need to prepare some 155 promotional text and you will need to create screenshots of your application. For more 156 information, see 157 <a href="https://www.google.com/support/androidmarket/developer/bin/answer.py?answer=1078870"> 158 Graphic Assets for your Application</a></p> 159 160 <h2 id="publishing-configure">Configuring Your Application for Release</h2> 161 162 <p>After you gather all of your supporting materials you can start configuring your application 163 for release. This section provides a summary of the configuration changes we recommend that you make 164 to your source code, resource files, and application manifest prior to releasing your application. 165 Although most of the configuration changes listed in this section are optional, they are 166 considered good coding practices and we encourage you to implement them. In some cases, 167 you may have already made these configuration changes as part of your development process.</p> 168 169 <h4>Choose a good package name</h4> 170 171 <p>Make sure you choose a package name that is suitable over the life of your application. You 172 cannot change the package name after you distribute your application to users. You can set the 173 package name in application's manifest file. For more information, see the <a 174 href="{@docRoot}guide/topics/manifest/manifest-element.html#package">package</a> attribute 175 documentation.</p> 176 177 <h4>Turn off logging and debugging</h4> 178 179 <p>Make sure you deactivate logging and disable the debugging option before you build your 180 application for release. You can deactivate logging by removing calls to 181 {@link android.util.Log} methods in your source files. You can disable debugging by removing the 182 <code>android:debuggable</code> attribute from the <code><application></code> tag in your 183 manifest file, or by setting the <code>android:debuggable</code> attribute to 184 <code>false</code> in your manifest file. Also, remove any log files or static test files that 185 were created in your project.</p> 186 187 <p>Also, you should remove all {@link android.os.Debug} tracing calls that you 188 added to your code, such as {@link android.os.Debug#startMethodTracing()} and 189 {@link android.os.Debug#stopMethodTracing()} method calls.</p> 190 191 <h4>Clean up your project directories</h4> 192 193 <p>Clean up your project and make sure it conforms to the directory structure described in <a 194 href="{@docRoot}guide/developing/projects/index.html#ApplicationProjects">Android Projects</a>. 195 Leaving stray or orphaned files in your project can prevent your application from compiling and 196 cause your application to behave unpredictably. At a minimum you should do the following cleanup 197 tasks:</p> 198 199 <ul> 200 <li>Review the contents of your <code>jni/</code>, <code>lib/</code>, and <code>src/</code> 201 directories. The <code>jni/</code> directory should contain only source files associated with the 202 <a href="{@docRoot}sdk/ndk/index.html">Android NDK</a>, such as 203 <code>.c</code>, <code>.cpp</code>, <code>.h</code>, and <code>.mk</code> files. The 204 <code>lib/</code> directory should contain only third-party library files or private library 205 files, including prebuilt shared and static libraries (for example, <code>.so</code> files). The 206 <code>src/</code> directory should contain only the source files for your application 207 (<code>.java</code> and <code>.aidl</code> files). The <code>src/</code> directory should not 208 contain any <code>.jar</code> files.</li> 209 <li>Check your project for private or proprietary data files that your application does not use 210 and remove them. For example, look in your project's <code>res/</code> directory for old 211 drawable files, layout files, and values files that you are no longer using and delete them.</li> 212 <li>Check your <code>lib/</code> directory for test libraries and remove them if they are no 213 longer being used by your application.</li> 214 <li>Review the contents of your <code>assets/</code> directory and your <code>res/raw/</code> 215 directory for raw asset files and static files that you need to update or remove prior to 216 release.</li> 217 </ul> 218 219 <h4>Review and update your manifest settings</h4> 220 221 <p>Verify that the following manifest items are set correctly:</p> 222 223 <ul> 224 <li><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> 225 <uses-permission></a> element 226 <p>You should specify only those permissions that are relevant and required for your application.</p> 227 </li> 228 <li><code>android:icon</code> and <code>android:label</code> attributes 229 <p>You must specify values for these attributes, which are located in the 230 <a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a> 231 element.</p> 232 </li> 233 <li><code>android:versionCode</code> and <code>android:versionName</code> attributes. 234 <p>We recommend that you specify values for these attributes, which are located in the 235 <a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a> 236 element. For more information see 237 <a href="{@docRoot}guide/publishing/versioning.html">Versioning your Application</a>.</p> 238 </li> 239 </ul> 240 241 <p>There are several additional manifest elements that you can set if you are releasing your 242 application on Android Market. For example, the <code>android:minSdkVersion</code> and 243 <code>android:targetSdkVersion</code> attributes, which are located in the <a 244 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"> <uses-sdk></a> element. For more 245 information about these and other Android Market settings, see <a 246 href="{@docRoot}/guide//appendix/market-filters.html">Market Filters</a>.</p> 247 248 <h4>Address compatibility issues</h4> 249 250 <p>Android provides several tools and techniques to make your application compatible with a wide 251 range of devices. To make your application available to the largest number of users, consider 252 doing the following:</p> 253 254 <ul> 255 <li><strong>Add support for multiple screen configurations</strong> 256 <p>Make sure you meet the 257 <a href="{@docRoot}guide/practices/screens_support.html#screen-independence"> 258 best practices for supporting multiple screens</a>. By supporting multiple screen configurations 259 you can create an application that functions properly and looks good on any of the screen sizes 260 supported by Android.</p> 261 </li> 262 <li><strong>Optimize your application for Android 3.0 devices.</strong> 263 <p>If your application is designed for devices older than Android 3.0, make it compatible 264 with Android 3.0 devices by following the guidelines and best practices described in 265 <a href="{@docRoot}guide/practices/optimizing-for-3.0.html">Optimizing Apps for Android 3.0 266 </a>.</p> 267 </li> 268 <li><strong>Consider using the Support Library</strong> 269 <p>If your application is designed for devices running Android 3.x, make your application 270 compatible with older versions of Android by adding the 271 <a href="{@docRoot}sdk/compatibility-library.html">Support Library</a> to your 272 application project. The Support Library provides static support libraries that you can add to 273 your Android application, which enables you to use APIs that are either not available on 274 older platform versions or use utility APIs that are not part of the framework APIs.</p> 275 </li> 276 </ul> 277 278 <h4>Update URLs for servers and services</h4> 279 280 <p>If your application accesses remote servers or services, make sure you are using the production 281 URL or path for the server or service and not a test URL or path.</p> 282 283 <h4>Implement Licensing (if you are releasing on Android Market)</h4> 284 285 <p>If you are releasing a paid application through Android Market, consider adding support for 286 Android Market Licensing. Licensing lets you control access to your application based on whether the 287 current user has purchased it. Using Android Market Licensing is optional even if you are 288 releasing your app through Android Market.</p> 289 290 <p>For more information about Android Market Licensing Service and how to use it in your 291 application, see <a href="{@docRoot}guide/publishing/licensing.html">Application Licensing</a>.</p> 292 293 <h2 id="publishing-build">Building Your Application for Release</h2> 294 295 <p>After you finish configuring your application you can build it into a release-ready 296 <code>.apk</code> fle that is signed and optimized. The JDK includes the tools for signing the 297 <code>.apk</code> file (Keytool and Jarsigner); the Android SDK includes the tools for compiling and 298 optimizing the <code>.apk</code> file. If you are using Eclipse with the ADT plugin or you are using 299 the Ant build script from the command line, you can automate the entire build process.</p> 300 301 <h3>Building with Eclipse</h3> 302 303 <p>You can use the Eclipse Export Wizard to build a release-ready <code>.apk</code> file that is 304 signed with your private key and optimized. To learn how to run the Export Wizard, see 305 <a href="{@docRoot}guide/publishing/app-signing.html#ExportWizard">Compile and sign with Eclipse 306 ADT</a>. The Export Wizard compiles your application for release, signs your application with your 307 private key, and optimizes your application with the zipalign tool. The Export Wizard should run 308 successfully if you have run or debugged your application from Eclipse and you have no errors in 309 your application (see <a href="{@docRoot}guide/developing/building/building-eclipse.html">Building 310 and Running from Eclipse with ADT</a> for more information.</p> 311 312 <p>The Export Wizard assumes that you have a <a href="#billing-keys">certificate and private key</a> 313 suitable for signing your application. If you do not have a suitable certificate and private key, 314 the Export Wizard will help you generate one (see 315 <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a> for more 316 information about the signing process and signing guidelines.</p> 317 318 <h3>Building with Ant</h3> 319 320 <p>You can use the Ant build script (included in the Android SDK) to build a release-ready 321 <code>.apk</code> file that is signed with your private key and optimized. To learn how to do this, 322 see <a href="{@docRoot}guide/developing/building/building-cmdline.html#ReleaseMode">Building in 323 Release Mode</a>. This build method assumes you have a <a href="#billing-keys">certificate and 324 private key</a> suitable for signing your application. If you do not have a suitable certificate and 325 private key, the Export Wizard will help you generate one (see 326 <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a> for more 327 information about the signing process and signing guidelines.</p> 328 329 <h2 id="publishing-resources">Preparing External Servers and Resources</h2> 330 331 <p>If your application relies on a remote server, make sure the server is secure and that it is 332 configured for production use. This is particularly important if you are implementing <a 333 href="{@docRoot}guide/market/billing/index.html">in-app billing</a> in your application and you are 334 performing the signature verification step on a remote server.</p> 335 336 <p>Also, if your application fetches content from a remote server or a real-time service (such as a 337 content feed), be sure the content you are providing is up to date and production-ready.</p> 338 339 <h2 id="publishing-test">Testing Your Application for Release</h2> 340 341 <p>Testing the release version of your application helps ensure that your application runs properly 342 under realistic device and network conditions. Ideally, you should test your application on at least 343 one handset-sized device and one tablet-sized device to verify that your user interface elements are 344 sized correctly and that your application's performance and battery efficiency are acceptable.</p> 345 346 <p>As a starting point for testing, see 347 <a href="{@docRoot}guide/topics/testing/what_to_test.html">What to Test</a>. This article provides 348 a summary of common Android situations that you should consider when you are testing. When you are 349 done testing and you are satisfied that the release version of your application 350 behaves correctly, you can release your application to users. For more information, see 351 <a href="{@docRoot}guide/publishing/publishing_overview.html#publishing-release">Releasing Your 352 Application to Users</a>. If you are publishing your application on Android Market, see 353 <a href="{@docRoot}guide/publishing/publishing.html">Publishing on Android Market</a>.</p> 354 355 356