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}tools/publishing/publishing_overview.html">Publishing Overview</a></li> 24 <li><a href="{@docRoot}tools/publishing/app-signing.html">Signing Your Applications</a></li> 25 <li><a href="{@docRoot}distribute/tools/launch-checklist.html">Launch Checklist for Google Play</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}tools/workflow/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 Google Play.</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 Google 47 Play, you should also read <a href="{@docRoot}distribute/tools/launch-checklist.html">Publishing 48 Checklist for Google Play</a> to be sure your release-ready application satisfies all Google Play 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}tools/workflow/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 Google Play you may want 93 to add special filtering rules to your manifest while you are configuring your application for 94 release. Similarly, to meet Google Play 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}tools/debugging/index.html">Debugging</a> and <a 101 href="{@docRoot}tools/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}tools/publishing/app-signing.html#cert">Obtain a 118 suitable private key</a>.</p> 119 120 <p class="caution"><strong>Important:</strong> Your application must be signed with a cryptographic 121 key whose validity period ends after 22 October 2033.</p> 122 123 <p>You may also have to obtain other release keys if your application accesses a service or uses a 124 third-party library that requires you to use a key that is based on your private key. For example, 125 if your application uses the <a 126 href="http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapView.html">MapView</a> 127 class, which is part of the <a 128 href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google Maps external 129 library</a>, you will need to register your application with the Google Maps service and obtain 130 a Maps API key. For information about getting a Maps API key, see <a 131 href="http://code.google.com/android/add-ons/google-apis/mapkey.html"> Obtaining a Maps API 132 key</a>.</p> 133 134 <h4>Application Icon</h4> 135 136 <p>Be sure you have an application icon and that it meets the recommended <a 137 href="{@docRoot}guide/practices/ui_guidelines/icon_design_launcher.html">icon guidelines</a>. Your 138 application's icon helps users identify your application on a device's Home 139 screen and in the Launcher window. It also appears in Manage Applications, My Downloads, and 140 elsewhere. In addition, publishing services such as Google Play display your icon to users.</p> 141 142 <p class="note"><strong>Note:</strong> If you are releasing your application on Google Play, you 143 need to create a high resolution 144 version of your icon. See <a 145 href="https://www.google.com/support/androidmarket/developer/bin/answer.py?answer=1078870">Graphic 146 Assets for your Application</a> for more information.</p> 147 148 <h4>End-user License Agreement</h4> 149 150 <p>Consider preparing an End User License Agreement (EULA) for your application. A EULA can help 151 protect your person, organization, and intellectual property, and we recommend that you provide one 152 with your application.</p> 153 154 <h4>Miscellaneous Materials</h4> 155 156 <p>You might also have to prepare promotional and marketing materials to publicize your application. 157 For example, if you are releasing your application on Google Play you will need to prepare some 158 promotional text and you will need to create screenshots of your application. For more 159 information, see 160 <a href="https://www.google.com/support/androidmarket/developer/bin/answer.py?answer=1078870"> 161 Graphic Assets for your Application</a></p> 162 163 <h2 id="publishing-configure">Configuring Your Application for Release</h2> 164 165 <p>After you gather all of your supporting materials you can start configuring your application 166 for release. This section provides a summary of the configuration changes we recommend that you make 167 to your source code, resource files, and application manifest prior to releasing your application. 168 Although most of the configuration changes listed in this section are optional, they are 169 considered good coding practices and we encourage you to implement them. In some cases, 170 you may have already made these configuration changes as part of your development process.</p> 171 172 <h4>Choose a good package name</h4> 173 174 <p>Make sure you choose a package name that is suitable over the life of your application. You 175 cannot change the package name after you distribute your application to users. You can set the 176 package name in application's manifest file. For more information, see the <a 177 href="{@docRoot}guide/topics/manifest/manifest-element.html#package">package</a> attribute 178 documentation.</p> 179 180 <h4>Turn off logging and debugging</h4> 181 182 <p>Make sure you deactivate logging and disable the debugging option before you build your 183 application for release. You can deactivate logging by removing calls to 184 {@link android.util.Log} methods in your source files. You can disable debugging by removing the 185 <code>android:debuggable</code> attribute from the <code><application></code> tag in your 186 manifest file, or by setting the <code>android:debuggable</code> attribute to 187 <code>false</code> in your manifest file. Also, remove any log files or static test files that 188 were created in your project.</p> 189 190 <p>Also, you should remove all {@link android.os.Debug} tracing calls that you 191 added to your code, such as {@link android.os.Debug#startMethodTracing()} and 192 {@link android.os.Debug#stopMethodTracing()} method calls.</p> 193 194 <p class="caution"><strong>Important:</strong> Ensure that you disable debugging for 195 your app if using {@link android.webkit.WebView} to display paid for content or if using JavaScript 196 interfaces, since debugging allows users to inject scripts and extract content using Chrome 197 DevTools. To disable debugging, use the 198 {@link android.webkit.WebView#setWebContentsDebuggingEnabled(boolean) WebView.setWebContentsDebuggingEnabled()} 199 method.</p> 200 201 <h4>Clean up your project directories</h4> 202 203 <p>Clean up your project and make sure it conforms to the directory structure described in <a 204 href="{@docRoot}tools/projects/index.html#ApplicationProjects">Android Projects</a>. 205 Leaving stray or orphaned files in your project can prevent your application from compiling and 206 cause your application to behave unpredictably. At a minimum you should do the following cleanup 207 tasks:</p> 208 209 <ul> 210 <li>Review the contents of your <code>jni/</code>, <code>lib/</code>, and <code>src/</code> 211 directories. The <code>jni/</code> directory should contain only source files associated with the 212 <a href="{@docRoot}tools/sdk/ndk/index.html">Android NDK</a>, such as 213 <code>.c</code>, <code>.cpp</code>, <code>.h</code>, and <code>.mk</code> files. The 214 <code>lib/</code> directory should contain only third-party library files or private library 215 files, including prebuilt shared and static libraries (for example, <code>.so</code> files). The 216 <code>src/</code> directory should contain only the source files for your application 217 (<code>.java</code> and <code>.aidl</code> files). The <code>src/</code> directory should not 218 contain any <code>.jar</code> files.</li> 219 <li>Check your project for private or proprietary data files that your application does not use 220 and remove them. For example, look in your project's <code>res/</code> directory for old 221 drawable files, layout files, and values files that you are no longer using and delete them.</li> 222 <li>Check your <code>lib/</code> directory for test libraries and remove them if they are no 223 longer being used by your application.</li> 224 <li>Review the contents of your <code>assets/</code> directory and your <code>res/raw/</code> 225 directory for raw asset files and static files that you need to update or remove prior to 226 release.</li> 227 </ul> 228 229 <h4>Review and update your manifest settings</h4> 230 231 <p>Verify that the following manifest items are set correctly:</p> 232 233 <ul> 234 <li><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> 235 <uses-permission></a> element 236 <p>You should specify only those permissions that are relevant and required for your application.</p> 237 </li> 238 <li><code>android:icon</code> and <code>android:label</code> attributes 239 <p>You must specify values for these attributes, which are located in the 240 <a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a> 241 element.</p> 242 </li> 243 <li><code>android:versionCode</code> and <code>android:versionName</code> attributes. 244 <p>We recommend that you specify values for these attributes, which are located in the 245 <a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a> 246 element. For more information see 247 <a href="{@docRoot}tools/publishing/versioning.html">Versioning your Application</a>.</p> 248 </li> 249 </ul> 250 251 <p>There are several additional manifest elements that you can set if you are releasing your 252 application on Google Play. For example, the <code>android:minSdkVersion</code> and 253 <code>android:targetSdkVersion</code> attributes, which are located in the <a 254 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"> <uses-sdk></a> element. For more 255 information about these and other Google Play settings, see <a 256 href="{@docRoot}google/play/filters.html">Filters on Google Play</a>.</p> 257 258 <h4>Address compatibility issues</h4> 259 260 <p>Android provides several tools and techniques to make your application compatible with a wide 261 range of devices. To make your application available to the largest number of users, consider 262 doing the following:</p> 263 264 <ul> 265 <li><strong>Add support for multiple screen configurations</strong> 266 <p>Make sure you meet the 267 <a href="{@docRoot}guide/practices/screens_support.html#screen-independence"> 268 best practices for supporting multiple screens</a>. By supporting multiple screen configurations 269 you can create an application that functions properly and looks good on any of the screen sizes 270 supported by Android.</p> 271 </li> 272 <li><strong>Optimize your application for Android tablet devices.</strong> 273 <p>If your application is designed for devices older than Android 3.0, make it compatible 274 with Android 3.0 devices by following the guidelines and best practices described in 275 <a href="{@docRoot}guide/practices/optimizing-for-3.0.html">Optimizing Apps for Android 3.0 276 </a>.</p> 277 </li> 278 <li><strong>Consider using the Support Library</strong> 279 <p>If your application is designed for devices running Android 3.x, make your application 280 compatible with older versions of Android by adding the 281 <a href="{@docRoot}tools/support-library/index.html">Support Library</a> to your 282 application project. The Support Library provides static support libraries that you can add to 283 your Android application, which enables you to use APIs that are either not available on 284 older platform versions or use utility APIs that are not part of the framework APIs.</p> 285 </li> 286 </ul> 287 288 <h4>Update URLs for servers and services</h4> 289 290 <p>If your application accesses remote servers or services, make sure you are using the production 291 URL or path for the server or service and not a test URL or path.</p> 292 293 <h4>Implement Licensing (if you are releasing on Google Play)</h4> 294 295 <p>If you are releasing a paid application through Google Play, consider adding support for 296 Google Play Licensing. Licensing lets you control access to your application based on whether the 297 current user has purchased it. Using Google Play Licensing is optional even if you are 298 releasing your app through Google Play.</p> 299 300 <p>For more information about Google Play Licensing Service and how to use it in your 301 application, see <a href="{@docRoot}google/play/licensing/index.html">Application Licensing</a>.</p> 302 303 <h2 id="publishing-build">Building Your Application for Release</h2> 304 305 <p>After you finish configuring your application you can build it into a release-ready 306 <code>.apk</code> fle that is signed and optimized. The JDK includes the tools for signing the 307 <code>.apk</code> file (Keytool and Jarsigner); the Android SDK includes the tools for compiling and 308 optimizing the <code>.apk</code> file. If you are using Eclipse with the ADT plugin or you are using 309 the Ant build script from the command line, you can automate the entire build process.</p> 310 311 <h3>Building with Eclipse</h3> 312 313 <p>You can use the Eclipse Export Wizard to build a release-ready <code>.apk</code> file that is 314 signed with your private key and optimized. To learn how to run the Export Wizard, see 315 <a href="{@docRoot}tools/publishing/app-signing.html#ExportWizard">Compile and sign with Eclipse 316 ADT</a>. The Export Wizard compiles your application for release, signs your application with your 317 private key, and optimizes your application with the zipalign tool. The Export Wizard should run 318 successfully if you have run or debugged your application from Eclipse and you have no errors in 319 your application (see <a href="{@docRoot}tools/building/building-eclipse.html">Building 320 and Running from Eclipse with ADT</a> for more information.</p> 321 322 <p>The Export Wizard assumes that you have a <a href="#billing-keys">certificate and private key</a> 323 suitable for signing your application. If you do not have a suitable certificate and private key, 324 the Export Wizard will help you generate one (see 325 <a href="{@docRoot}tools/publishing/app-signing.html">Signing Your Applications</a> for more 326 information about the signing process and signing guidelines.</p> 327 328 <h3>Building with Ant</h3> 329 330 <p>You can use the Ant build script (included in the Android SDK) to build a release-ready 331 <code>.apk</code> file that is signed with your private key and optimized. To learn how to do this, 332 see <a href="{@docRoot}tools/building/building-cmdline.html#ReleaseMode">Building in 333 Release Mode</a>. This build method assumes you have a <a href="#billing-keys">certificate and 334 private key</a> suitable for signing your application. If you do not have a suitable certificate and 335 private key, the Export Wizard will help you generate one (see 336 <a href="{@docRoot}tools/publishing/app-signing.html">Signing Your Applications</a> for more 337 information about the signing process and signing guidelines.</p> 338 339 <h2 id="publishing-resources">Preparing External Servers and Resources</h2> 340 341 <p>If your application relies on a remote server, make sure the server is secure and that it is 342 configured for production use. This is particularly important if you are implementing <a 343 href="{@docRoot}google/play/billing/index.html">in-app billing</a> in your application and you are 344 performing the signature verification step on a remote server.</p> 345 346 <p>Also, if your application fetches content from a remote server or a real-time service (such as a 347 content feed), be sure the content you are providing is up to date and production-ready.</p> 348 349 <h2 id="publishing-test">Testing Your Application for Release</h2> 350 351 <p>Testing the release version of your application helps ensure that your application runs properly 352 under realistic device and network conditions. Ideally, you should test your application on at least 353 one handset-sized device and one tablet-sized device to verify that your user interface elements are 354 sized correctly and that your application's performance and battery efficiency are acceptable.</p> 355 356 <p>As a starting point for testing, see 357 <a href="{@docRoot}tools/testing/what_to_test.html">What to Test</a>. This article provides 358 a summary of common Android situations that you should consider when you are testing. When you are 359 done testing and you are satisfied that the release version of your application 360 behaves correctly, you can release your application to users. For more information, see 361 <a href="{@docRoot}tools/publishing/publishing_overview.html#publishing-release">Releasing Your 362 Application to Users</a>. If you are publishing your application on Google Play, see 363 <a href="{@docRoot}distribute/tools/launch-checklist.html">Launch Checklist 364 for Google Play</a>.</p> 365 366 367