1page.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 31preparation process is a required <a href="{@docRoot}tools/workflow/index.html">development 32task</a> for all Android applications and is the first step in the publishing process (see figure 331).</p> 34 35<p>When you prepare your application for release, you configure, build, and test a release 36version of your application. The configuration tasks are straightforward, involving basic code 37cleanup and code modification tasks that help optimize your application. The build process is 38similar to the debug build process and can be done using JDK and Android SDK tools. The testing 39tasks serve as a final check, ensuring that your application performs as expected under real-world 40conditions. 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 42application marketplace such as Google Play.</p> 43 44<p>This document summarizes the main tasks you need to perform to prepare your application for 45release. The tasks that are described in this document apply to all Android applications regardless 46how they are released or distributed to users. If you are releasing your application through Google 47Play, you should also read <a href="{@docRoot}distribute/tools/launch-checklist.html">Publishing 48Checklist for Google Play</a> to be sure your release-ready application satisfies all Google Play 49requirements.</p> 50 51<p class="note"><strong>Note:</strong> As a best practice, your application should meet all of your 52release criteria for functionality, performance, and stability before you perform the tasks outlined 53in 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 61href="{@docRoot}tools/workflow/index.html">development 62task</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 68install and run on their Android-powered devices. The release-ready package contains the same 69components as the debug <code>.apk</code> file — compiled source code, resources, manifest 70file, 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 72and 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 85Android Studio. For example, you can use Android Studio with the Gradle build files to compile, sign, 86and optimize your application all at once. You can also configure the Gradle build files to do the 87same when you build from the command line. For more details about using the Gradle build files, see 88the <a href="{@docRoot}sdk/installing/studio-build.html">Build System</a> guide.</p> 89 90<p>To prepare your application for release you typically perform five main tasks (see figure 2). 91Each main task may include one or more smaller tasks depending on how you are releasing your 92application. For example, if you are releasing your application through Google Play you may want 93to add special filtering rules to your manifest while you are configuring your application for 94release. Similarly, to meet Google Play publishing guidelines you may have to prepare screenshots 95and 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 98your application. The Android SDK contains several tools to help you test and debug your Android 99applications. For more information, see the <a 100href="{@docRoot}tools/debugging/index.html">Debugging</a> and <a 101href="{@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 106minimum this includes cryptographic keys for signing your application and an application icon. You 107might 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 112certificate that is owned by the application's developer (that is, a certificate for which the 113developer holds the private key). The Android system uses the certificate as a means of identifying 114the author of an application and establishing trust relationships between applications. The 115certificate that you use for signing does not need to be signed by a certificate authority; the 116Android system allows you to sign your applications with a self-signed certificate. To learn about 117certificate requirements, see <a href="{@docRoot}tools/publishing/app-signing.html">Signing Your 118Applications</a>.</p> 119 120<p class="caution"><strong>Important:</strong> Your application must be signed with a cryptographic 121key 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 124third-party library that requires you to use a key that is based on your private key. For example, 125if your application uses the <a 126href="http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapView.html">MapView</a> 127class, which is part of the <a 128href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google Maps external 129library</a>, you will need to register your application with the Google Maps service and obtain 130a Maps API key. For information about getting a Maps API key, see <a 131href="http://code.google.com/android/add-ons/google-apis/mapkey.html"> Obtaining a Maps API 132key</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 137href="{@docRoot}guide/practices/ui_guidelines/icon_design_launcher.html">icon guidelines</a>. Your 138application's icon helps users identify your application on a device's Home 139screen and in the Launcher window. It also appears in Manage Applications, My Downloads, and 140elsewhere. 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 143need to create a high resolution 144 version of your icon. See <a 145href="https://www.google.com/support/androidmarket/developer/bin/answer.py?answer=1078870">Graphic 146Assets 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 151protect your person, organization, and intellectual property, and we recommend that you provide one 152with 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. 157For example, if you are releasing your application on Google Play you will need to prepare some 158promotional text and you will need to create screenshots of your application. For more 159information, see 160<a href="https://www.google.com/support/androidmarket/developer/bin/answer.py?answer=1078870"> 161Graphic 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 166for release. This section provides a summary of the configuration changes we recommend that you make 167to your source code, resource files, and application manifest prior to releasing your application. 168Although most of the configuration changes listed in this section are optional, they are 169considered good coding practices and we encourage you to implement them. In some cases, 170you 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 175cannot change the package name after you distribute your application to users. You can set the 176package name in application's manifest file. For more information, see the <a 177href="{@docRoot}guide/topics/manifest/manifest-element.html#package">package</a> attribute 178documentation.</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 183application 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 186manifest 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 188were created in your project.</p> 189 190<p>Also, you should remove all {@link android.os.Debug} tracing calls that you 191added 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 195your app if using {@link android.webkit.WebView} to display paid for content or if using JavaScript 196interfaces, since debugging allows users to inject scripts and extract content using Chrome 197DevTools. To disable debugging, use the 198{@link android.webkit.WebView#setWebContentsDebuggingEnabled(boolean) WebView.setWebContentsDebuggingEnabled()} 199method.</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 204href="{@docRoot}tools/projects/index.html#ApplicationProjects">Android Projects</a>. 205Leaving stray or orphaned files in your project can prevent your application from compiling and 206cause your application to behave unpredictably. At a minimum you should do the following cleanup 207tasks:</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 and Gradle build settings</h4> 230 231<p>Verify that the following manifest and build files 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 or build file elements that you can set if you are releasing your 252application on Google Play. For example, the <code>android:minSdkVersion</code> and 253<code>android:targetSdkVersion</code> attributes, which are located in the <a 254href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"> <uses-sdk></a> element. For more 255information about these and other Google Play settings, see <a 256href="{@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 261range of devices. To make your application available to the largest number of users, consider 262doing 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 291URL 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 296Google Play Licensing. Licensing lets you control access to your application based on whether the 297current user has purchased it. Using Google Play Licensing is optional even if you are 298releasing your app through Google Play.</p> 299 300<p>For more information about Google Play Licensing Service and how to use it in your 301application, 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> file 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 308optimizing the <code>.apk</code> file. If you are using Android Studio or you are using 309the Gradle build system from the command line, you can automate the entire build process. 310For more information about configuring Gradle builds, see 311<a href="{@docRoot}tools/building/configuring-gradle.html">Configuring Gradle Builds</a>.</p> 312 313<h3>Building with Android Studio</h3> 314 315<p>You can use the Gradle build system, integrated with Android Studio to build a release-ready 316<code>.apk</code> file that is signed with your private key and optimized. To learn how to setup and 317run builds from Android Studio, see 318<a href="{@docRoot}tools/building/building-studio.html">Building and Running from Android Studio</a>.</p> 319 320<p>The build process assumes that you have a certificate and private key 321suitable for signing your application. If you do not have a suitable certificate and private key, 322Android Studio can help you generate one. For more information about the signing process, see 323<a href="{@docRoot}tools/publishing/app-signing.html">Signing Your Applications</a>.</p> 324 325 326<h2 id="publishing-resources">Preparing External Servers and Resources</h2> 327 328<p>If your application relies on a remote server, make sure the server is secure and that it is 329configured for production use. This is particularly important if you are implementing <a 330href="{@docRoot}google/play/billing/index.html">in-app billing</a> in your application and you are 331performing the signature verification step on a remote server.</p> 332 333<p>Also, if your application fetches content from a remote server or a real-time service (such as a 334content feed), be sure the content you are providing is up to date and production-ready.</p> 335 336<h2 id="publishing-test">Testing Your Application for Release</h2> 337 338<p>Testing the release version of your application helps ensure that your application runs properly 339under realistic device and network conditions. Ideally, you should test your application on at least 340one handset-sized device and one tablet-sized device to verify that your user interface elements are 341sized correctly and that your application's performance and battery efficiency are acceptable.</p> 342 343<p>As a starting point for testing, see 344<a href="{@docRoot}tools/testing/what_to_test.html">What to Test</a>. This article provides 345a summary of common Android situations that you should consider when you are testing. When you are 346done testing and you are satisfied that the release version of your application 347behaves correctly, you can release your application to users. For more information, see 348<a href="{@docRoot}tools/publishing/publishing_overview.html#publishing-release">Releasing Your 349Application to Users</a>. If you are publishing your application on Google Play, see 350<a href="{@docRoot}distribute/tools/launch-checklist.html">Launch Checklist 351for Google Play</a>.</p> 352 353 354